38
1 / 38 ZF2rapid ZF2rapid Zend Framework 2 Anwendungen im Handumdrehen Zend Framework 2 Anwendungen im Handumdrehen Repository: https://github.com/RalfEggert/ipc2015-zf2rapid Repository: https://github.com/RalfEggert/ipc2015-zf2rapid

IPC 2015 ZF2rapid

Embed Size (px)

Citation preview

Page 1: IPC 2015 ZF2rapid

1 / 38

ZF2rapidZF2rapidZend Framework 2 Anwendungen im HandumdrehenZend Framework 2 Anwendungen im Handumdrehen

Repository: https://github.com/RalfEggert/ipc2015-zf2rapidRepository: https://github.com/RalfEggert/ipc2015-zf2rapid

Page 2: IPC 2015 ZF2rapid

2 / 38

www.ralfeggert.dewww.ralfeggert.de

Über michÜber mich

Page 3: IPC 2015 ZF2rapid

Fragen an das PublikumFragen an das Publikum33 / / 3838

[b01][b01]

Page 4: IPC 2015 ZF2rapid

[B02][B02]

44 / / 3838

ZF2rapid in a nutshellZF2rapid in a nutshell

Page 5: IPC 2015 ZF2rapid

5 / 38

ZFrapidZFrapid

http://zfrapid.org/

https://github.com/ZFrapid

ZF2 MVC(ZF3 MVC)

(ZF3 Middleware)

Page 6: IPC 2015 ZF2rapid

ProjekteProjekte ModuleModule Code GenerierungCode Generierung

Routing & MapsRouting & Maps KonfigurationKonfiguration CRUDCRUD

6 / 38

[B05][B05][B04][B04][B03][B03]

[B08][B08][B07][B07][B06][B06]

ZF2rapid FeaturesZF2rapid Features

Page 7: IPC 2015 ZF2rapid

7 / 38

// Mit Git clonen und mit Composer installieren$ cd /home/devhost/$ git clone https://github.com/ZFrapid/zf2rapid.git zf2rapid$ cd zf2rapid$ composer install

// Lokale Installation testen$ ./bin/zf2rapid.php

// Dynamischen Link erstellen$ sudo ln -s /home/devhost/zf2rapid/bin/zf2rapid.php /usr/local/bin/zf2rapid

// Details zur Installation (auch unter Windows) unter// https://github.com/ZFrapid/zf2rapid/blob/master/docs/installation.md

ZF2rapid InstallationZF2rapid Installation

Page 8: IPC 2015 ZF2rapid

[b03][b03]

88 / / 3838

ProjekteProjekte

Page 9: IPC 2015 ZF2rapid

9 / 38

$ zf2rapid create-project --help

===========================================================================Usage: create-project [--workingPath=]

Arguments: --workingPath= The path to work in; defaults to current working path

Help:

Create a new ZF2 project within the specified path===========================================================================

$ cd /home/devhost/$ zf2rapid create-project --workingPath=myproject$ cd myproject/

Projekt anlegenProjekt anlegen

Page 10: IPC 2015 ZF2rapid

10 / 38

$ zf2rapid tool-config

{ "configFileFormat": "php", "flagAddDocBlocks": "true", "fileDocBlockText": "ZF2 Application built by ZF2rapid", "fileDocBlockCopyright": "(c) 2015 John Doe", "fileDocBlockLicense": "http://opensource.org/licenses/MIT MITLicense", "namespaceController": "Controller", "namespaceControllerPlugin": "Controller\\Plugin", "namespaceViewHelper": "View\\Helper", "namespaceFilter": "Model\\Filter", "namespaceValidator": "Model\\Validator", "namespaceInputFilter": "Model\\InputFilter", "namespaceForm": "Form", "namespaceHydrator": "Model\\Hydrator", "namespaceEntity": "Model\\Entity", "namespaceTableGateway": "Model\\TableGateway", "namespaceRepository": "Model\\Repository"}

Projekt konfigurierenProjekt konfigurieren

Page 11: IPC 2015 ZF2rapid

[b04][b04]

1111 / / 3838

ModuleModule

Page 12: IPC 2015 ZF2rapid

12 / 38

$ zf2rapid create-module --help

===========================================================================Usage: create-module <module> [--workingPath=] [--configFile=] [--without-project] [--no-activation]

Arguments: <module> The name of the module to create; mandatory --workingPath= The path to work in; defaults to current working path --configFile= Specify the configuration file to activate or deactivate a module in; defaults to not bet set --without-project Ignore if working path does not contain a ZF2 project; defaults to current working path --no-activation Prevent the activation of the new module (disabled by default)

Help:

Create a new module within the specified path===========================================================================

Modul anlegenModul anlegen

Page 13: IPC 2015 ZF2rapid

13 / 38

// Modul anlegen$ zf2rapid create-module Shop

// Modul löschen$ zf2rapid delete-module Shop

// Modul aktivieren$ zf2rapid activate-module Shop

// Modul deaktivieren$ zf2rapid deactivate-module Shop

// Konfigurationsdatei mit angeben$ zf2rapid create-module Shop --configFile=development.config.php

// Modul unabhängig vom Zend Framework 2 Projekt anlegen$ zf2rapid create-module Shop --without-project --workingPath=/some/where

Mit Modulen arbeitenMit Modulen arbeiten

Page 14: IPC 2015 ZF2rapid

[b00][b00]

1414 / / 3838

Code anschauenCode anschauen

Page 15: IPC 2015 ZF2rapid

[b05][b05]

1515 / / 3838

Code generierungCode generierung

Page 16: IPC 2015 ZF2rapid

16 / 38

$ zf2rapid create-controller --help

===========================================================================Usage: create-controller <module> <controller> [--workingPath=] [--without-project] [--no-factory]

Arguments: <module> The name of the module to create the controller in; mandatory <controller> The name of the controller to create; mandatory --workingPath= The path to work in; defaults to current working path --without-project Ignore if working path does not contain a ZF2 project; defaults to current working path --no-factory Prevent the creation of a factory for the new controller

Help:

Create a new controller for module within the specified path===========================================================================

Controller anlegenController anlegen

Page 17: IPC 2015 ZF2rapid

17 / 38

$ zf2rapid create-action --help

===========================================================================Usage: create-action <module> <controller> <action> [--workingPath=] [--without-project]

Arguments: <module> The name of the module to create the controller action in; mandatory <controller> The name of the controller to create an action for; mandatory <action> The name of the new action to create; mandatory --workingPath= The path to work in; defaults to current working path --without-project Ignore if working path does not contain a ZF2 project; defaults to current working path

Help:

Create a new controller action for module within the specified path===========================================================================

Action anlegenAction anlegen

Page 18: IPC 2015 ZF2rapid

18 / 38

$ zf2rapid create-view-helper --help

===========================================================================Usage: create-view-helper <module> <viewHelper> [--workingPath=] [--without-project] [--no-factory]

Arguments: <module> The name of the module to create the view helper in; mandatory <viewHelper> The name of the view helper to create; mandatory --workingPath= The path to work in; defaults to current working path --without-project Ignore if working path does not contain a ZF2 project; defaults to current working path --no-factory Prevent the creation of a factory for the new view helper

Help:

Create a new view helper for module within the specified path===========================================================================

View Helper anlegenView Helper anlegen

Page 19: IPC 2015 ZF2rapid

19 / 38

// Validator anlegen$ zf2rapid create-validator Shop Basket

// Hydrator anlegen, der ClassMethods Hydrator erweitert$ zf2rapid create-hydrator Shop Basket --baseHydrator=ClassMethods

// Formular anlegen$ zf2rapid create-form Shop Basket

// Alle Module anzeigen$ zf2rapid show-modules

// Alle Controller anzeigen$ zf2rapid show-controllers

// Alle Aktionen anzeigen$ zf2rapid show-actions

Weitere MöglichkeitenWeitere Möglichkeiten

Page 20: IPC 2015 ZF2rapid

[b00][b00]

2020 / / 3838

Code anschauenCode anschauen

Page 21: IPC 2015 ZF2rapid

[b06][b06]

2121 / / 3838

Routing & MapsRouting & Maps

Page 22: IPC 2015 ZF2rapid

22 / 38

// Routing anlegen$ zf2rapid create-routing Shop

// Striktes Routing anlegen$ zf2rapid create-routing Shop --strict

// Class Map generieren$ zf2rapid generate-classmap Shop

// Template Map generieren$ zf2rapid generate-templatemap Shop

Routing und Maps anlegenRouting und Maps anlegen

Page 23: IPC 2015 ZF2rapid

[b00][b00]

2323 / / 3838

Code anschauenCode anschauen

Page 24: IPC 2015 ZF2rapid

[b00][b00]

2424 / / 3838

Im Browser anschauenIm Browser anschauen

Page 25: IPC 2015 ZF2rapid

[b08][b08]

2525 / / 3838

CRUDCRUD

Page 26: IPC 2015 ZF2rapid

26 / 38

DatenbankmodellDatenbankmodell

Page 27: IPC 2015 ZF2rapid

27 / 38

// Datei /config/autoload/development.phpreturn array( 'db' => array( 'driver' => 'pdo', 'dsn' => 'mysql:dbname=ipc2015.zf2rapid;host=localhost; charset=utf8', 'user' => 'ipc2015', 'pass' => 'ipc2015', ),);

// Datenbankverbindung prüfen$ zf2rapid crud-check-db

// Datenbanktabellen anzeigen$ zf2rapid crud-show-tables

CRUD Datenbank konfigurierenCRUD Datenbank konfigurieren

Page 28: IPC 2015 ZF2rapid

28 / 38

$ zf2rapid create-module BlogDomain --configFile=development.config.php$ zf2rapid crud-create-model BlogDomain article,category,author

$ zf2rapid crud-create-model --help

===========================================================================Usage: crud-create-model <module> <tables> [--workingPath=]

Arguments: <module> The name of the module to create the model classes in; mandatory <tables> The names of the database tables to create the model classes for; mandatory --workingPath= The path to work in; defaults to current working path

Help:

Create all model classes (entity, hydrator, table gateway, repository) for a database table===========================================================================

CRUD Model anlegenCRUD Model anlegen

Page 29: IPC 2015 ZF2rapid

[b00][b00]

2929 / / 3838

Code anschauenCode anschauen

Page 30: IPC 2015 ZF2rapid

30 / 38

$ zf2rapid create-module AuthorAdmin --configFile=development.config.php$ zf2rapid create-module CategoryAdmin --configFile=development.config.php$ zf2rapid create-module ArticleAdmin --configFile=development.config.php$ zf2rapid crud-create-application AuthorAdmin BlogDomain/AuthorEntity$ zf2rapid crud-create-application CategoryAdmin BlogDomain/CategoryEntity$ zf2rapid crud-create-application ArticleAdmin BlogDomain/ArticleEntity

$ zf2rapid crud-create-application --help===========================================================================Usage: crud-create-application <module> <entity> [--workingPath=]

Arguments: <module> The name of the module to create the application in; <entity> The entity to create the application for with the format ModuleName/EntityClassName; mandatory --workingPath= The path to work in; defaults to current working path

Help: Create application (controller, view) for a model entity===========================================================================

CRUD Application anlegenCRUD Application anlegen

Page 31: IPC 2015 ZF2rapid

[b00][b00]

3131 / / 3838

Code anschauenCode anschauen

Page 32: IPC 2015 ZF2rapid

[b00][b00]

3232 / / 3838

Im Browser anschauenIm Browser anschauen

Page 33: IPC 2015 ZF2rapid

[b09][b09]

3333 / / 3838

FinetuningFinetuning

Page 34: IPC 2015 ZF2rapid

[b10][b10]

3434 / / 3838

Wichtige Warnung!Wichtige Warnung!

Page 35: IPC 2015 ZF2rapid

[b11][b11]

3535 / / 3838

Testen, Bugs & FeaturesTesten, Bugs & Features

Page 36: IPC 2015 ZF2rapid

Fragen vom Publikum?Fragen vom Publikum?3636 / / 3838

[b12][b12]

Page 37: IPC 2015 ZF2rapid

3737 / / 3838

DankeDankeFür Ihre / Eure AufmerksamkeitFür Ihre / Eure Aufmerksamkeit

Repository: https://github.com/RalfEggert/ipc2015-zf2rapidRepository: https://github.com/RalfEggert/ipc2015-zf2rapidSlides: http://de.slideshare.net/eggertralf/ipc2015-zf2rapidSlides: http://de.slideshare.net/eggertralf/ipc2015-zf2rapid

Page 38: IPC 2015 ZF2rapid

BildnachweisBildnachweis

[B00] Fotos von Ralf Eggert

[B01] Frontiers 2011 - Day 2 https://www.flickr.com/photos/frontiersofinteraction/5866676276/ von Frontiersofinteraction - CC-BY https://creativecommons.org/licenses/by/2.0/

[B02] My nuts https://www.flickr.com/photos/lucasincas/6517703315/ von Lucas Incas - CC-BY https://creativecommons.org/licenses/by/2.0/

[B03] Harbourside Building Site 4 https://www.flickr.com/photos/matt_gibson/420273270/ von Matt Gibson - CC-BY https://creativecommons.org/licenses/by/2.0/

[B04] rainbow cubes with holes https://www.flickr.com/photos/generated/6313491064/ von Jared Tarbell - CC-BY https://creativecommons.org/licenses/by/2.0/

[B05] Monaco-14pt https://www.flickr.com/photos/polarity/3138680190/ von Robert Agthe - CC-BY https://creativecommons.org/licenses/by/2.0/

[B06] Scenic Route 207 Texas Plain Trail https://www.flickr.com/photos/mtsrs/2547608404/ von mtsrs - CC-BY https://creativecommons.org/licenses/by/2.0/

[B07] Molecular Bonds https://www.flickr.com/photos/pasukaru76/6978143982/ von Pascal - CC-BY https://creativecommons.org/licenses/by/2.0/

[B08] Fixing the database https://www.flickr.com/photos/dahlstroms/4140461901 von Håkan Dahlström - CC-BY https://creativecommons.org/licenses/by/2.0/

[B09] Swiss Army Knife https://www.flickr.com/photos/askdavetaylor/4261149346/ von Dave Taylor - CC-BY https://creativecommons.org/licenses/by/2.0/

[B10] Warning https://www.flickr.com/photos/thomasletholsen/9369862678/ von Thomas Leth-Olsen- CC-BY-SA https://creativecommons.org/licenses/by-sa/2.0/

[B11] Help wanted sign https://www.flickr.com/photos/andjohan/5644714850/ von Andreas Klinke Johannsen - CC-BY-SA https://creativecommons.org/licenses/by-sa/2.0/

[B12] Etech05: Audience https://www.flickr.com/photos/oreilly/6648470 von James Duncan Davidson - CC-BY https://creativecommons.org/licenses/by/2.0/

[B13] Jobs https://www.flickr.com/photos/jakerust/16844967041/ von www.gotcredit.com - CC-BY https://creativecommons.org/licenses/by/2.0/

ZFrapid Logo von Moritz Liebeknecht.

Alle weiteren Screenshots wurden von Ralf Eggert erstellt.

38 / 38