SlideShare una empresa de Scribd logo
1 de 47
Getting Started with
Aura
Chris Tankersley
NomadPHP EU June 2015
NomadPHP EU, June 2015 1
Who Am I
• PHP Programmer for over 10 years
• Work/know a lot of different
languages, even COBOL
• Primarily do Zend Framework 2
• https://github.com/dragonmantank
NomadPHP EU, June 2015 2
Professional Tools for Professional
Applications
NomadPHP EU, June 2015 3
About Aura
• Started by Paul M. Jones
• Maintained by him and the community
• Originally a rewrite of Solar (not Solr)
• There are three versions, 1.x, 2.x, and a 3.x!
• Works well by themselves, or in supplied Bundles/Kernels/Projects
NomadPHP EU, June 2015 4
Requirements
• PHP 5.3 or PHP 5.4, depending on the package
NomadPHP EU, June 2015 5
Each Package is Self Contained
NomadPHP EU, June 2015 6
http://looselycoupled.info/
Getting Started
NomadPHP EU, June 2015 7
2 Steps
• Find a package you want on https://github.com/auraphp
• Install via Composer
NomadPHP EU, June 2015 8
Winning was never so easy!
NomadPHP EU, June 2015 9
Aura is built to use whatever, whenever
• Aura.Filter
• Aura.Router
• Aura.Sql
• Aura.SqlQuery
• Aura.Di
• Aura.Http
• Aura.Html
• Aura.Session
NomadPHP EU, June 2015 10
• Aura.Cli
• Aura.View
• Aura.Intl
• Aura.Input
• Aura.Includer
• Aura.Dispatcher
• Aura.Auth
Or go all in
• Aura.SqlMapper_Bundle
• Aura.Framework_Project
• Aura.Web_Project
• Aura.Web_Kernel
• Aura.Cli_Project
• Aura.Cli_Kernel
NomadPHP EU, June 2015 11
Most Common Packages
NomadPHP EU, June 2015 12
Aura.Di
NomadPHP EU, June 2015 13
Dependency Injection, Not Service
Location
• Provides a way to lazily create services
• Interface for providing Constructor and Setter Injection
• Can provide auto resolution to injection, you should probably turn it
off though
NomadPHP EU, June 2015 14
NomadPHP EU, June 2015 15
use AuraDiContainer as DiContainer;
use AuraDiFactory as DiFactory;
$di = new DiContainer(new DiFactory());
$di->set('database.handler', function() use ($di) {
$config = $di->get('config');
return new AuraSqlExtendedPdo(
'mysql:host='.$config['db']['host'].';dbname='.$config['db']['dbname'],
$config['db']['username'],
$config['db']['password']
);
});
$di->params['AuraSqlQueryQueryFactory'] = array(
'db' => 'mysql'
);
$di->set('database.query_handler', $di->lazyNew('AuraSqlQueryQueryFactory'));
Aura.Router
NomadPHP EU, June 2015 16
Almost like a micro-framework
• Provides a way to match a route to a chunk of code
• Can handle different HTTP verbs
• Can filter parameters based on regex
• Can set default parameters
• Generate URLs from the attached routes
NomadPHP EU, June 2015 17
Setting up a Route
NomadPHP EU, June 2015 18
$router_factory = new AuraRouterRouterFactory();
$router = $router_factory->newInstance();
$router
->addPost('bitbucket_webhook', '/api/v0/bitbucket/webhook/{token}')
->addTokens([
'token' => 'w+',
])
->addValues(array(
'controller' => 'bitbucket',
'action' => 'webhook',
))
;
Dispatching
NomadPHP EU, June 2015 19
$app = function ($request, $response) use($di, $router) {
$server['REQUEST_METHOD'] = $request->getMethod();
$route = $router->match($request->getPath(), $server);
if(!$route) {
echo sprintf('[%s] %s 404', date('Y-m-d H:i:s'), $request->getPath()).PHP_EOL;
$response->writeHead(404, array('Content-Type' => 'text/plain'));
$response->end('404');
return;
} else {
$controllerName = ‘MyAppController'.ucfirst($route->params['controller']).'Controller';
$actionName = $route->params['action'].'Action';
$controller = new $controllerName($request, $response, $di);
$controller->$actionName();
}
};
Aura.Dispatcher
NomadPHP EU, June 2015 20
It’s an Object Mapper
• Maps names to objects, and then invokes them in some way
• Will continue to dispatch until there is nothing left to do
NomadPHP EU, June 2015 21
NomadPHP EU, June 2015 22
$dispatcher = new AuraDispatcherDispatcher();
$dispatcher->setObjectParam('controller');
$dispatcher->setMethodParam('action');
$dispatcher->setObject('projects', $di->lazyNew('PrimusAppCommandProjectsCommand'));
$argv = $context->argv->get();
if(count($argv) < 2) {
$stdio = $di->get('cli.stdio');
$stdio->outln('Please enter a commmand to run');
die();
}
$controller = $argv[1];
if(isset($argv[2])) {
$args = $context->argv->get();
$action = $args[2].'Action';
} else {
$action = 'indexAction';
}
$dispatcher->__invoke(compact('controller', 'action'));
Aura.SqlQuery
NomadPHP EU, June 2015 23
Fluent Query Builder
• Generates SQL for MySQL, Postgres, SQLite, and SQL Server
• Does not require a DB connection
• Select, Insert, Update, and Delete builders are available
NomadPHP EU, June 2015 24
NomadPHP EU, June 2015 25
protected function buildSelectQuery($table, $criteria = array(), $cols = array('*'), $order = 'id ASC') {
$select = $this->queryHandler->newSelect();
$select
->cols($cols)
->from($table)
->orderBy(array($order))
;
foreach($criteria as $column => $value) {
$select->where($column.' = :'.$column);
}
if(!empty($criteria)) {
$select->bindValues($criteria);
}
return $select;
}
public function save($data, $table, $identifierColumn = 'id') {
$data = $this->convertToArray($data);
if(!empty($data[$identifierColumn])) {
// Removed for brevity
} else {
$insert = $this->queryHandler->newInsert();
$insert
->into($table)
->cols(array_keys($data))
->bindValues($data)
;
$this->db->perform($insert->__toString(), $insert->getBindValues());
$name = $insert->getLastInsertIdName($identifierColumn);
return $this->db->lastInsertId($name);
}
}
NomadPHP EU, June 2015 26
/**
* Returns a single result based on the criteria
* Criteria must be an array, with the DB column the key and the DB value the value
*
* @param array $criteria Search criteria
* @param string $table Table to search against
* @return array
*/
public function find($criteria, $table)
{
$select = $this->buildSelectQuery($table, $criteria);
return $this->db->fetchOne($select->__toString(), $select->getBindValues());
}
Aura.Sql
NomadPHP EU, June 2015 27
A Better Wrapper around PDO
• Lazy connections to your DB
• Allows you to quote arrays of strings
• Prepare, bind and fetch in one step
• SQL Profiler to see what went on during a query
NomadPHP EU, June 2015 28
NomadPHP EU, June 2015 29
use AuraDiContainer as DiContainer;
use AuraDiFactory as DiFactory;
$di = new DiContainer(new DiFactory());
$di->set('database.handler', function() use ($di) {
$config = $di->get('config');
return new AuraSqlExtendedPdo(
'mysql:host='.$config['db']['host'].';dbname='.$config['db']['dbname'],
$config['db']['username'],
$config['db']['password']
);
});
$di->params['AuraSqlQueryQueryFactory'] = array(
'db' => 'mysql'
);
$di->set('database.query_handler', $di->lazyNew('AuraSqlQueryQueryFactory'));
NomadPHP EU, June 2015 30
public function delete($criteria, $table)
{
$delete = $this->queryHandler->newDelete();
$delete->from($table);
foreach($criteria as $col => $value) {
$delete->where($col.' = :'.$col);
}
$delete->bindValues($criteria);
return $this->db->perform($delete->__toString(), $delete->getBindValues());
}
public function fetchAllBy($criteria, $table, $order = 'id ASC')
{
$select = $this->buildSelectQuery($table, $criteria, array('*'), $order);
return $this->db->fetchAll($select->__toString(), $select->getBindValues());
}
Aura.Cli
NomadPHP EU, June 2015 31
Very nice wrapper around the CLI
• Wraps the request and response for CLI interfaces
• Supports options and help
NomadPHP EU, June 2015 32
Setup
NomadPHP EU, June 2015 33
use AuraCliCliFactory;
$cli_factory = new CliFactory();
$context = $cli_factory->newContext($GLOBALS);
$cli_stdio = $cli_factory->newStdio();
NomadPHP EU, June 2015 34
public function createAction()
{
$opts = $this->context->getopt(array('name:', 'repo:', 'branch:', 'deploy-path:'));
// ...
$name = $opts->get('--name');
$repo = $opts->get('--repo');
while (empty($name)) {
$stdio->out('Please enter the name of this project: ');
$name = $stdio->in();
}
// ...
}
public function deployAction()
{
$args = $this->context->argv->get();
$project = $this->projectService->fetchProject($args[3]);
if($project && $project->active) {
$deploymentService = $this->di->get('service.deployment');
$deploymentService->deploy($project);
$this->stdio->outln('Deployed');
} else {
$this->stdio->outln('There is no project by that name');
}
}
Aura.Filter
NomadPHP EU, June 2015 35
Better Filtering and Sanitization
• Provides a better interface for filtering than the Filter module
• Ships with a ton of filters and validators
• Allows chains of commands for working with data
• Provides soft, hard, and full stop validation chains
NomadPHP EU, June 2015 36
NomadPHP EU, June 2015 37
NomadPHP EU, June 2015 38
Bundles, Kernels, and Projects
NomadPHP EU, June 2015 39
Using modules as building blocks
• Bundles are larger-weight versions of the individual packages
• Kernels are ‘core’ logic for projects
• Projects are more like using ZF2 or Symfony 2 as full stacks
NomadPHP EU, June 2015 40
Aura.SqlMapper_Bundle
• Use at your own risk
• Links together Aura.Sql and Aura.SqlQuery into a mapper pattern
NomadPHP EU, June 2015 41
Project Kernel, Web Kernel, CLI Kernel
• Provides the core setup for the Web and CLI projects
• Mostly config and classes. Still needs wired up to work fully
• You can create your own custom kernels by basing it off Project Kernel
NomadPHP EU, June 2015 42
Web Project, CLI Project
• Full stack project skeletons for those project types
• They pull in a specific Kernel, and bootstrap from there
• Make heavy use of Aura.Di, so make sure you know how to use it
NomadPHP EU, June 2015 43
Web Project
• Web Project follows Action Domain Responder instead of the normal
MVC
• Can be used as a Micro Framework or as a Full Stack
NomadPHP EU, June 2015 44
Questions?
NomadPHP EU, June 2015 45
Thank You!
http://ctankersley.com
chris@ctankersley.com
@dragonmantank
https://joind.in/14632
NomadPHP EU, June 2015 46
Notes
• Code is taken from:
• https://github.com/dragonmantank/primus
• https://github.com/dragonmantank/casket
• All code in this presentation is available under the MIT license
NomadPHP EU, June 2015 47

Más contenido relacionado

La actualidad más candente

How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with dockerRuoshi Ling
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopWalter Heck
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
Puppet control-repo 
to the next level
Puppet control-repo 
to the next levelPuppet control-repo 
to the next level
Puppet control-repo 
to the next levelAlessandro Franceschi
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for DummiesŁukasz Proszek
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with AnsibleIvan Serdyuk
 
Ship your Scala code often and easy with Docker
Ship your Scala code often and easy with DockerShip your Scala code often and easy with Docker
Ship your Scala code often and easy with DockerMarcus Lönnberg
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
Puppet at Pinterest
Puppet at PinterestPuppet at Pinterest
Puppet at PinterestPuppet
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principlesPerl Careers
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecMartin Etmajer
 
Managing Puppet using MCollective
Managing Puppet using MCollectiveManaging Puppet using MCollective
Managing Puppet using MCollectivePuppet
 
Puppet at GitHub / ChatOps
Puppet at GitHub / ChatOpsPuppet at GitHub / ChatOps
Puppet at GitHub / ChatOpsPuppet
 

La actualidad más candente (20)

How to deploy PHP projects with docker
How to deploy PHP projects with dockerHow to deploy PHP projects with docker
How to deploy PHP projects with docker
 
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & HadoopPuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
PuppetCamp SEA 1 - Using Vagrant, Puppet, Testing & Hadoop
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Intro to PSGI and Plack
Intro to PSGI and PlackIntro to PSGI and Plack
Intro to PSGI and Plack
 
Plack at YAPC::NA 2010
Plack at YAPC::NA 2010Plack at YAPC::NA 2010
Plack at YAPC::NA 2010
 
Puppet control-repo 
to the next level
Puppet control-repo 
to the next levelPuppet control-repo 
to the next level
Puppet control-repo 
to the next level
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Ship your Scala code often and easy with Docker
Ship your Scala code often and easy with DockerShip your Scala code often and easy with Docker
Ship your Scala code often and easy with Docker
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 
Puppet at Pinterest
Puppet at PinterestPuppet at Pinterest
Puppet at Pinterest
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
 
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpecTest-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
Test-Driven Infrastructure with Ansible, Test Kitchen, Serverspec and RSpec
 
Managing Puppet using MCollective
Managing Puppet using MCollectiveManaging Puppet using MCollective
Managing Puppet using MCollective
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
 
Puppet at GitHub / ChatOps
Puppet at GitHub / ChatOpsPuppet at GitHub / ChatOps
Puppet at GitHub / ChatOps
 

Similar a Getting Started With Aura

Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHPPaul Jones
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.xJoão Ventura
 
Web automation with #d8rules (European Drupal Days 2015)
Web automation with #d8rules (European Drupal Days 2015)Web automation with #d8rules (European Drupal Days 2015)
Web automation with #d8rules (European Drupal Days 2015)Eugenio Minardi
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
Aura for PHP at Fossmeet 2014
Aura for PHP at Fossmeet 2014Aura for PHP at Fossmeet 2014
Aura for PHP at Fossmeet 2014Hari K T
 
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)Robert Nelson
 
PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T
PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T
PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T Puppet
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk GötzNETWAYS
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Coder Presentation Boston
Coder Presentation BostonCoder Presentation Boston
Coder Presentation BostonDoug Green
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)p3castro
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6Nobuo Danjou
 
DrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewDrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewlittleMAS
 

Similar a Getting Started With Aura (20)

Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
Web automation with #d8rules (European Drupal Days 2015)
Web automation with #d8rules (European Drupal Days 2015)Web automation with #d8rules (European Drupal Days 2015)
Web automation with #d8rules (European Drupal Days 2015)
 
CakePHP
CakePHPCakePHP
CakePHP
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
Aura for PHP at Fossmeet 2014
Aura for PHP at Fossmeet 2014Aura for PHP at Fossmeet 2014
Aura for PHP at Fossmeet 2014
 
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
Enjoying the Journey from Puppet 3.x to Puppet 4.x (PuppetConf 2016)
 
PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T
PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T
PuppetConf 2016: Enjoying the Journey from Puppet 3.x to 4.x – Rob Nelson, AT&T
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
Coder Presentation Boston
Coder Presentation BostonCoder Presentation Boston
Coder Presentation Boston
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6plackdo, plack-like web interface on perl6
plackdo, plack-like web interface on perl6
 
Best practices tekx
Best practices tekxBest practices tekx
Best practices tekx
 
DrupalCon LA 2015 Review
DrupalCon LA 2015 ReviewDrupalCon LA 2015 Review
DrupalCon LA 2015 Review
 

Más de Chris Tankersley

Docker is Dead: Long Live Containers
Docker is Dead: Long Live ContainersDocker is Dead: Long Live Containers
Docker is Dead: Long Live ContainersChris Tankersley
 
Bend time to your will with git
Bend time to your will with gitBend time to your will with git
Bend time to your will with gitChris Tankersley
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Chris Tankersley
 
Dead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPIDead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPIChris Tankersley
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for DevelopmentChris Tankersley
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Chris Tankersley
 
BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018Chris Tankersley
 
You Were Lied To About Optimization
You Were Lied To About OptimizationYou Were Lied To About Optimization
You Were Lied To About OptimizationChris Tankersley
 
Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017Chris Tankersley
 
Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017Chris Tankersley
 
Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Chris Tankersley
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Chris Tankersley
 
OOP Is More Then Cars and Dogs - Midwest PHP 2017
OOP Is More Then Cars and Dogs - Midwest PHP 2017OOP Is More Then Cars and Dogs - Midwest PHP 2017
OOP Is More Then Cars and Dogs - Midwest PHP 2017Chris Tankersley
 
From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017Chris Tankersley
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPChris Tankersley
 
Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016Chris Tankersley
 
How We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open SourceHow We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open SourceChris Tankersley
 

Más de Chris Tankersley (20)

Docker is Dead: Long Live Containers
Docker is Dead: Long Live ContainersDocker is Dead: Long Live Containers
Docker is Dead: Long Live Containers
 
Bend time to your will with git
Bend time to your will with gitBend time to your will with git
Bend time to your will with git
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)
 
Dead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPIDead Simple APIs with OpenAPI
Dead Simple APIs with OpenAPI
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
You Got Async in my PHP!
You Got Async in my PHP!You Got Async in my PHP!
You Got Async in my PHP!
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
They are Watching You
They are Watching YouThey are Watching You
They are Watching You
 
BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018BASHing at the CLI - Midwest PHP 2018
BASHing at the CLI - Midwest PHP 2018
 
You Were Lied To About Optimization
You Were Lied To About OptimizationYou Were Lied To About Optimization
You Were Lied To About Optimization
 
Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017Docker for PHP Developers - php[world] 2017
Docker for PHP Developers - php[world] 2017
 
Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017Docker for PHP Developers - Madison PHP 2017
Docker for PHP Developers - Madison PHP 2017
 
Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017
 
OOP Is More Then Cars and Dogs - Midwest PHP 2017
OOP Is More Then Cars and Dogs - Midwest PHP 2017OOP Is More Then Cars and Dogs - Midwest PHP 2017
OOP Is More Then Cars and Dogs - Midwest PHP 2017
 
From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017From Docker to Production - SunshinePHP 2017
From Docker to Production - SunshinePHP 2017
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHP
 
Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016Coming to Terms with OOP In Drupal - php[world] 2016
Coming to Terms with OOP In Drupal - php[world] 2016
 
How We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open SourceHow We Got Here: A Brief History of Open Source
How We Got Here: A Brief History of Open Source
 

Último

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Último (20)

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Getting Started With Aura

  • 1. Getting Started with Aura Chris Tankersley NomadPHP EU June 2015 NomadPHP EU, June 2015 1
  • 2. Who Am I • PHP Programmer for over 10 years • Work/know a lot of different languages, even COBOL • Primarily do Zend Framework 2 • https://github.com/dragonmantank NomadPHP EU, June 2015 2
  • 3. Professional Tools for Professional Applications NomadPHP EU, June 2015 3
  • 4. About Aura • Started by Paul M. Jones • Maintained by him and the community • Originally a rewrite of Solar (not Solr) • There are three versions, 1.x, 2.x, and a 3.x! • Works well by themselves, or in supplied Bundles/Kernels/Projects NomadPHP EU, June 2015 4
  • 5. Requirements • PHP 5.3 or PHP 5.4, depending on the package NomadPHP EU, June 2015 5
  • 6. Each Package is Self Contained NomadPHP EU, June 2015 6 http://looselycoupled.info/
  • 8. 2 Steps • Find a package you want on https://github.com/auraphp • Install via Composer NomadPHP EU, June 2015 8
  • 9. Winning was never so easy! NomadPHP EU, June 2015 9
  • 10. Aura is built to use whatever, whenever • Aura.Filter • Aura.Router • Aura.Sql • Aura.SqlQuery • Aura.Di • Aura.Http • Aura.Html • Aura.Session NomadPHP EU, June 2015 10 • Aura.Cli • Aura.View • Aura.Intl • Aura.Input • Aura.Includer • Aura.Dispatcher • Aura.Auth
  • 11. Or go all in • Aura.SqlMapper_Bundle • Aura.Framework_Project • Aura.Web_Project • Aura.Web_Kernel • Aura.Cli_Project • Aura.Cli_Kernel NomadPHP EU, June 2015 11
  • 12. Most Common Packages NomadPHP EU, June 2015 12
  • 14. Dependency Injection, Not Service Location • Provides a way to lazily create services • Interface for providing Constructor and Setter Injection • Can provide auto resolution to injection, you should probably turn it off though NomadPHP EU, June 2015 14
  • 15. NomadPHP EU, June 2015 15 use AuraDiContainer as DiContainer; use AuraDiFactory as DiFactory; $di = new DiContainer(new DiFactory()); $di->set('database.handler', function() use ($di) { $config = $di->get('config'); return new AuraSqlExtendedPdo( 'mysql:host='.$config['db']['host'].';dbname='.$config['db']['dbname'], $config['db']['username'], $config['db']['password'] ); }); $di->params['AuraSqlQueryQueryFactory'] = array( 'db' => 'mysql' ); $di->set('database.query_handler', $di->lazyNew('AuraSqlQueryQueryFactory'));
  • 17. Almost like a micro-framework • Provides a way to match a route to a chunk of code • Can handle different HTTP verbs • Can filter parameters based on regex • Can set default parameters • Generate URLs from the attached routes NomadPHP EU, June 2015 17
  • 18. Setting up a Route NomadPHP EU, June 2015 18 $router_factory = new AuraRouterRouterFactory(); $router = $router_factory->newInstance(); $router ->addPost('bitbucket_webhook', '/api/v0/bitbucket/webhook/{token}') ->addTokens([ 'token' => 'w+', ]) ->addValues(array( 'controller' => 'bitbucket', 'action' => 'webhook', )) ;
  • 19. Dispatching NomadPHP EU, June 2015 19 $app = function ($request, $response) use($di, $router) { $server['REQUEST_METHOD'] = $request->getMethod(); $route = $router->match($request->getPath(), $server); if(!$route) { echo sprintf('[%s] %s 404', date('Y-m-d H:i:s'), $request->getPath()).PHP_EOL; $response->writeHead(404, array('Content-Type' => 'text/plain')); $response->end('404'); return; } else { $controllerName = ‘MyAppController'.ucfirst($route->params['controller']).'Controller'; $actionName = $route->params['action'].'Action'; $controller = new $controllerName($request, $response, $di); $controller->$actionName(); } };
  • 21. It’s an Object Mapper • Maps names to objects, and then invokes them in some way • Will continue to dispatch until there is nothing left to do NomadPHP EU, June 2015 21
  • 22. NomadPHP EU, June 2015 22 $dispatcher = new AuraDispatcherDispatcher(); $dispatcher->setObjectParam('controller'); $dispatcher->setMethodParam('action'); $dispatcher->setObject('projects', $di->lazyNew('PrimusAppCommandProjectsCommand')); $argv = $context->argv->get(); if(count($argv) < 2) { $stdio = $di->get('cli.stdio'); $stdio->outln('Please enter a commmand to run'); die(); } $controller = $argv[1]; if(isset($argv[2])) { $args = $context->argv->get(); $action = $args[2].'Action'; } else { $action = 'indexAction'; } $dispatcher->__invoke(compact('controller', 'action'));
  • 24. Fluent Query Builder • Generates SQL for MySQL, Postgres, SQLite, and SQL Server • Does not require a DB connection • Select, Insert, Update, and Delete builders are available NomadPHP EU, June 2015 24
  • 25. NomadPHP EU, June 2015 25 protected function buildSelectQuery($table, $criteria = array(), $cols = array('*'), $order = 'id ASC') { $select = $this->queryHandler->newSelect(); $select ->cols($cols) ->from($table) ->orderBy(array($order)) ; foreach($criteria as $column => $value) { $select->where($column.' = :'.$column); } if(!empty($criteria)) { $select->bindValues($criteria); } return $select; } public function save($data, $table, $identifierColumn = 'id') { $data = $this->convertToArray($data); if(!empty($data[$identifierColumn])) { // Removed for brevity } else { $insert = $this->queryHandler->newInsert(); $insert ->into($table) ->cols(array_keys($data)) ->bindValues($data) ; $this->db->perform($insert->__toString(), $insert->getBindValues()); $name = $insert->getLastInsertIdName($identifierColumn); return $this->db->lastInsertId($name); } }
  • 26. NomadPHP EU, June 2015 26 /** * Returns a single result based on the criteria * Criteria must be an array, with the DB column the key and the DB value the value * * @param array $criteria Search criteria * @param string $table Table to search against * @return array */ public function find($criteria, $table) { $select = $this->buildSelectQuery($table, $criteria); return $this->db->fetchOne($select->__toString(), $select->getBindValues()); }
  • 28. A Better Wrapper around PDO • Lazy connections to your DB • Allows you to quote arrays of strings • Prepare, bind and fetch in one step • SQL Profiler to see what went on during a query NomadPHP EU, June 2015 28
  • 29. NomadPHP EU, June 2015 29 use AuraDiContainer as DiContainer; use AuraDiFactory as DiFactory; $di = new DiContainer(new DiFactory()); $di->set('database.handler', function() use ($di) { $config = $di->get('config'); return new AuraSqlExtendedPdo( 'mysql:host='.$config['db']['host'].';dbname='.$config['db']['dbname'], $config['db']['username'], $config['db']['password'] ); }); $di->params['AuraSqlQueryQueryFactory'] = array( 'db' => 'mysql' ); $di->set('database.query_handler', $di->lazyNew('AuraSqlQueryQueryFactory'));
  • 30. NomadPHP EU, June 2015 30 public function delete($criteria, $table) { $delete = $this->queryHandler->newDelete(); $delete->from($table); foreach($criteria as $col => $value) { $delete->where($col.' = :'.$col); } $delete->bindValues($criteria); return $this->db->perform($delete->__toString(), $delete->getBindValues()); } public function fetchAllBy($criteria, $table, $order = 'id ASC') { $select = $this->buildSelectQuery($table, $criteria, array('*'), $order); return $this->db->fetchAll($select->__toString(), $select->getBindValues()); }
  • 32. Very nice wrapper around the CLI • Wraps the request and response for CLI interfaces • Supports options and help NomadPHP EU, June 2015 32
  • 33. Setup NomadPHP EU, June 2015 33 use AuraCliCliFactory; $cli_factory = new CliFactory(); $context = $cli_factory->newContext($GLOBALS); $cli_stdio = $cli_factory->newStdio();
  • 34. NomadPHP EU, June 2015 34 public function createAction() { $opts = $this->context->getopt(array('name:', 'repo:', 'branch:', 'deploy-path:')); // ... $name = $opts->get('--name'); $repo = $opts->get('--repo'); while (empty($name)) { $stdio->out('Please enter the name of this project: '); $name = $stdio->in(); } // ... } public function deployAction() { $args = $this->context->argv->get(); $project = $this->projectService->fetchProject($args[3]); if($project && $project->active) { $deploymentService = $this->di->get('service.deployment'); $deploymentService->deploy($project); $this->stdio->outln('Deployed'); } else { $this->stdio->outln('There is no project by that name'); } }
  • 36. Better Filtering and Sanitization • Provides a better interface for filtering than the Filter module • Ships with a ton of filters and validators • Allows chains of commands for working with data • Provides soft, hard, and full stop validation chains NomadPHP EU, June 2015 36
  • 37. NomadPHP EU, June 2015 37
  • 38. NomadPHP EU, June 2015 38
  • 39. Bundles, Kernels, and Projects NomadPHP EU, June 2015 39
  • 40. Using modules as building blocks • Bundles are larger-weight versions of the individual packages • Kernels are ‘core’ logic for projects • Projects are more like using ZF2 or Symfony 2 as full stacks NomadPHP EU, June 2015 40
  • 41. Aura.SqlMapper_Bundle • Use at your own risk • Links together Aura.Sql and Aura.SqlQuery into a mapper pattern NomadPHP EU, June 2015 41
  • 42. Project Kernel, Web Kernel, CLI Kernel • Provides the core setup for the Web and CLI projects • Mostly config and classes. Still needs wired up to work fully • You can create your own custom kernels by basing it off Project Kernel NomadPHP EU, June 2015 42
  • 43. Web Project, CLI Project • Full stack project skeletons for those project types • They pull in a specific Kernel, and bootstrap from there • Make heavy use of Aura.Di, so make sure you know how to use it NomadPHP EU, June 2015 43
  • 44. Web Project • Web Project follows Action Domain Responder instead of the normal MVC • Can be used as a Micro Framework or as a Full Stack NomadPHP EU, June 2015 44
  • 47. Notes • Code is taken from: • https://github.com/dragonmantank/primus • https://github.com/dragonmantank/casket • All code in this presentation is available under the MIT license NomadPHP EU, June 2015 47