├── README.md ├── expressive ├── .gitignore ├── LICENSE.md ├── README.md ├── bin │ └── clear-config-cache.php ├── composer.json ├── composer.lock ├── config │ ├── .gitignore │ ├── autoload │ │ ├── .gitignore │ │ ├── dependencies.global.php │ │ ├── development.local.php.dist │ │ ├── local.php.dist │ │ └── zend-expressive.global.php │ ├── config.php │ ├── container.php │ ├── development.config.php.dist │ ├── pipeline.php │ └── routes.php ├── data │ ├── .gitignore │ └── cache │ │ └── .gitkeep ├── phpcs.xml.dist ├── phpunit.xml.dist ├── public │ ├── .htaccess │ └── index.php ├── src │ └── App │ │ ├── ConfigProvider.php │ │ └── Handler │ │ ├── HomePageHandler.php │ │ ├── HomePageHandlerFactory.php │ │ └── PingHandler.php ├── templates │ ├── app │ │ └── home-page.phtml │ ├── error │ │ ├── 404.phtml │ │ └── error.phtml │ └── layout │ │ └── default.phtml └── test │ └── AppTest │ └── Handler │ ├── HomePageHandlerFactoryTest.php │ ├── HomePageHandlerTest.php │ └── PingHandlerTest.php └── mvc ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── TODO.md ├── Vagrantfile ├── composer.json ├── composer.lock ├── config ├── application.config.php ├── autoload │ ├── .gitignore │ ├── README.md │ ├── development.local.php.dist │ ├── global.php │ ├── local.php.dist │ └── zend-developer-tools.local-development.php ├── development.config.php.dist └── modules.config.php ├── data └── cache │ └── .gitignore ├── docker-compose.yml ├── module ├── Admin │ ├── config │ │ └── module.config.php │ ├── src │ │ ├── Controller │ │ │ ├── AdminController.php │ │ │ ├── AdminControllerFactory.php │ │ │ ├── GroupsController.php │ │ │ └── UsersController.php │ │ └── Module.php │ └── view │ │ ├── admin │ │ ├── admin │ │ │ ├── index.phtml │ │ │ └── runmigrations.phtml │ │ ├── groups │ │ │ ├── index.phtml │ │ │ └── view.phtml │ │ └── users │ │ │ ├── activity.phtml │ │ │ ├── groups.phtml │ │ │ ├── index.phtml │ │ │ ├── settings.phtml │ │ │ └── timeline.phtml │ │ └── layout │ │ └── layout.phtml ├── Portal │ ├── config │ │ └── module.config.php │ ├── src │ │ ├── Controller │ │ │ ├── IndexController.php │ │ │ ├── ProfileController.php │ │ │ └── UserRelatedControllerFactory.php │ │ └── Module.php │ ├── test │ │ └── Controller │ │ │ └── IndexControllerTest.php │ └── view │ │ ├── error │ │ ├── 404.phtml │ │ └── index.phtml │ │ ├── layout │ │ └── layout.phtml │ │ └── portal │ │ ├── index │ │ └── index.phtml │ │ └── profile │ │ ├── edit.phtml │ │ └── view.phtml └── ZFT │ ├── Module.php │ ├── src │ ├── Assets │ │ ├── Image.php │ │ └── ImageHydrator.php │ ├── Authentication │ │ └── AuthenticationServiceFactory.php │ ├── Connections │ │ └── LdapFactory.php │ ├── JsonSelect.php │ ├── Migrations │ │ ├── Migrations.php │ │ ├── MigrationsEvent.php │ │ └── Platform │ │ │ ├── Postgresql.php │ │ │ └── SqlServerMigrations.php │ └── User │ │ ├── DataMapperInterface.php │ │ ├── Group.php │ │ ├── IdentityMapInterface.php │ │ ├── MemoryIdentityMap.php │ │ ├── PostgresDataMapper.php │ │ ├── Repository.php │ │ ├── RepositoryFactory.php │ │ ├── User.php │ │ └── UserDataMapper.php │ └── test │ ├── Assets │ ├── ImageHydratorTest.php │ └── ImageTest.php │ ├── Authentication │ └── AuthenticationFactoryTest.php │ ├── CompositeHydratorTest.php │ ├── Connections │ └── LdapFactoryTest.php │ ├── Migrations │ └── MigrationsTest.php │ ├── User │ ├── RepositoryFactoryTest.php │ └── UserRepositoryTest.php │ └── UserTest.php ├── phpunit.xml.dist └── public ├── .htaccess ├── LICENSE ├── css ├── AdminLTE.css ├── AdminLTE.min.css ├── bootstrap-theme.css ├── bootstrap-theme.css.map ├── bootstrap-theme.min.css ├── bootstrap-theme.min.css.map ├── bootstrap.css ├── bootstrap.css.map ├── bootstrap.min.css ├── bootstrap.min.css.map ├── skins │ ├── _all-skins.css │ ├── _all-skins.min.css │ ├── skin-black-light.css │ ├── skin-black-light.min.css │ ├── skin-black.css │ ├── skin-black.min.css │ ├── skin-blue-light.css │ ├── skin-blue-light.min.css │ ├── skin-blue.css │ ├── skin-blue.min.css │ ├── skin-green-light.css │ ├── skin-green-light.min.css │ ├── skin-green.css │ ├── skin-green.min.css │ ├── skin-purple-light.css │ ├── skin-purple-light.min.css │ ├── skin-purple.css │ ├── skin-purple.min.css │ ├── skin-red-light.css │ ├── skin-red-light.min.css │ ├── skin-red.css │ ├── skin-red.min.css │ ├── skin-yellow-light.css │ ├── skin-yellow-light.min.css │ ├── skin-yellow.css │ └── skin-yellow.min.css └── style.css ├── favicon.ico ├── fonts ├── glyphicons-halflings-regular.eot ├── glyphicons-halflings-regular.svg ├── glyphicons-halflings-regular.ttf ├── glyphicons-halflings-regular.woff └── glyphicons-halflings-regular.woff2 ├── img ├── avatar.png ├── avatar04.png ├── avatar2.png ├── avatar3.png ├── avatar5.png ├── boxed-bg.jpg ├── boxed-bg.png ├── credit │ ├── american-express.png │ ├── cirrus.png │ ├── mastercard.png │ ├── mestro.png │ ├── paypal.png │ ├── paypal2.png │ └── visa.png ├── default-50x50.gif ├── favicon.ico ├── icons.png ├── photo1.png ├── photo2.png ├── photo3.jpg ├── photo4.jpg ├── user1-128x128.jpg ├── user2-160x160.jpg ├── user3-128x128.jpg ├── user4-128x128.jpg ├── user5-128x128.jpg ├── user6-128x128.jpg ├── user7-128x128.jpg ├── user8-128x128.jpg ├── user_1.png ├── user_10.png ├── user_100.png ├── user_11.png ├── user_12.png ├── user_13.png ├── user_14.png ├── user_15.png ├── user_16.png ├── user_17.png ├── user_18.png ├── user_19.png ├── user_2.png ├── user_20.png ├── user_21.png ├── user_22.png ├── user_23.png ├── user_24.png ├── user_25.png ├── user_26.png ├── user_27.png ├── user_28.png ├── user_29.png ├── user_3.png ├── user_30.png ├── user_31.png ├── user_32.png ├── user_33.png ├── user_34.png ├── user_35.png ├── user_36.png ├── user_37.png ├── user_38.png ├── user_39.png ├── user_4.png ├── user_40.png ├── user_41.png ├── user_42.png ├── user_43.png ├── user_44.png ├── user_45.png ├── user_46.png ├── user_47.png ├── user_48.png ├── user_49.png ├── user_5.png ├── user_50.png ├── user_51.png ├── user_52.png ├── user_53.png ├── user_54.png ├── user_55.png ├── user_56.png ├── user_57.png ├── user_58.png ├── user_59.png ├── user_6.png ├── user_60.png ├── user_61.png ├── user_62.png ├── user_63.png ├── user_64.png ├── user_65.png ├── user_66.png ├── user_67.png ├── user_68.png ├── user_69.png ├── user_7.png ├── user_70.png ├── user_71.png ├── user_72.png ├── user_73.png ├── user_74.png ├── user_75.png ├── user_76.png ├── user_77.png ├── user_78.png ├── user_79.png ├── user_8.png ├── user_80.png ├── user_81.png ├── user_82.png ├── user_83.png ├── user_84.png ├── user_85.png ├── user_86.png ├── user_87.png ├── user_88.png ├── user_89.png ├── user_9.png ├── user_90.png ├── user_91.png ├── user_92.png ├── user_93.png ├── user_94.png ├── user_95.png ├── user_96.png ├── user_97.png ├── user_98.png ├── user_99.png └── zf-logo.png ├── index.php ├── js ├── app.js ├── app.min.js ├── bootstrap.js ├── bootstrap.min.js ├── demo.js ├── jquery-2.2.4.min.js └── pages │ ├── dashboard.js │ └── dashboard2.js ├── plugins ├── img │ └── switch.png └── multi-select │ ├── jquery.multi-select.js │ └── multi-select.dist.css └── web.config /README.md: -------------------------------------------------------------------------------- 1 | # Zend Framework and Expressive Tutorial Repository 2 | 3 | These are sources for tutorials published at [Alex Tech Adventures](http://alex-tech-adventures.com) and 4 | [YouTube](https://www.youtube.com/playlist?list=PLXRC3l-ZhN3o7yOeUSjLlXKLI1FCDcEQv). 5 | The tutorial is derived from original Zend Skeleton application. You can view full original install README file at [Original MVC Repository](https://github.com/zendframework/ZendSkeletonApplication). and at [Original Expressive Repository](https://github.com/zendframework/zend-expressive-skeleton) 6 | 7 | You can use issue tracker to report problems or suggestions. 8 | 9 | --- 10 | 11 | Thank you very much for the donation offers! These tutorials are very long to produce. Extra donations 12 | will help towards doing this work sustainably without going on extended breaks. 13 | 14 | [![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PET8HPTAH3BVU) 15 | -------------------------------------------------------------------------------- /expressive/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | composer.phar 3 | clover.xml 4 | coveralls-upload.json 5 | phpunit.xml 6 | vendor/ 7 | -------------------------------------------------------------------------------- /expressive/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2018, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, this 12 | list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /expressive/bin/clear-config-cache.php: -------------------------------------------------------------------------------- 1 | [ 10 | // Use 'aliases' to alias a service name to another service. The 11 | // key is the alias name, the value is the service to which it points. 12 | 'aliases' => [ 13 | // Fully\Qualified\ClassOrInterfaceName::class => Fully\Qualified\ClassName::class, 14 | ], 15 | // Use 'invokables' for constructor-less services, or services that do 16 | // not require arguments to the constructor. Map a service name to the 17 | // class name. 18 | 'invokables' => [ 19 | // Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class, 20 | ], 21 | // Use 'factories' for services provided by callbacks/factory classes. 22 | 'factories' => [ 23 | // Fully\Qualified\ClassName::class => Fully\Qualified\FactoryName::class, 24 | ], 25 | ], 26 | ]; 27 | -------------------------------------------------------------------------------- /expressive/config/autoload/development.local.php.dist: -------------------------------------------------------------------------------- 1 | [ 19 | 'invokables' => [ 20 | ], 21 | 'factories' => [ 22 | ErrorResponseGenerator::class => Container\WhoopsErrorResponseGeneratorFactory::class, 23 | 'Zend\Expressive\Whoops' => Container\WhoopsFactory::class, 24 | 'Zend\Expressive\WhoopsPageHandler' => Container\WhoopsPageHandlerFactory::class, 25 | ], 26 | ], 27 | 28 | 'whoops' => [ 29 | 'json_exceptions' => [ 30 | 'display' => true, 31 | 'show_trace' => true, 32 | 'ajax_only' => true, 33 | ], 34 | ], 35 | ]; 36 | -------------------------------------------------------------------------------- /expressive/config/autoload/local.php.dist: -------------------------------------------------------------------------------- 1 | true, 13 | 14 | // Enable debugging; typically used to provide debugging information within templates. 15 | 'debug' => false, 16 | 17 | 'zend-expressive' => [ 18 | // Provide templates for the error handling middleware to use when 19 | // generating responses. 20 | 'error_handler' => [ 21 | 'template_404' => 'error::404', 22 | 'template_error' => 'error::error', 23 | ], 24 | ], 25 | ]; 26 | -------------------------------------------------------------------------------- /expressive/config/config.php: -------------------------------------------------------------------------------- 1 | 'data/cache/config-cache.php', 13 | ]; 14 | 15 | $aggregator = new ConfigAggregator([ 16 | \Zend\Expressive\ZendView\ConfigProvider::class, 17 | \Zend\Expressive\Router\FastRouteRouter\ConfigProvider::class, 18 | \Zend\HttpHandlerRunner\ConfigProvider::class, 19 | // Include cache configuration 20 | new ArrayProvider($cacheConfig), 21 | 22 | \Zend\Expressive\Helper\ConfigProvider::class, 23 | \Zend\Expressive\ConfigProvider::class, 24 | \Zend\Expressive\Router\ConfigProvider::class, 25 | 26 | // Swoole config to overwrite some services (if installed) 27 | class_exists(\Zend\Expressive\Swoole\ConfigProvider::class) 28 | ? \Zend\Expressive\Swoole\ConfigProvider::class 29 | : function(){ return[]; }, 30 | 31 | // Default App module config 32 | App\ConfigProvider::class, 33 | 34 | // Load application config in a pre-defined order in such a way that local settings 35 | // overwrite global settings. (Loaded as first to last): 36 | // - `global.php` 37 | // - `*.global.php` 38 | // - `local.php` 39 | // - `*.local.php` 40 | new PhpFileProvider(realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php'), 41 | 42 | // Load development config if it exists 43 | new PhpFileProvider(realpath(__DIR__) . '/development.config.php'), 44 | ], $cacheConfig['config_cache_path']); 45 | 46 | return $aggregator->getMergedConfig(); 47 | -------------------------------------------------------------------------------- /expressive/config/container.php: -------------------------------------------------------------------------------- 1 | true, 29 | ConfigAggregator::ENABLE_CACHE => false, 30 | ]; 31 | -------------------------------------------------------------------------------- /expressive/config/pipeline.php: -------------------------------------------------------------------------------- 1 | pipe(ErrorHandler::class); 25 | $app->pipe(ServerUrlMiddleware::class); 26 | 27 | // Pipe more middleware here that you want to execute on every request: 28 | // - bootstrapping 29 | // - pre-conditions 30 | // - modifications to outgoing responses 31 | // 32 | // Piped Middleware may be either callables or service names. Middleware may 33 | // also be passed as an array; each item in the array must resolve to 34 | // middleware eventually (i.e., callable or service name). 35 | // 36 | // Middleware can be attached to specific paths, allowing you to mix and match 37 | // applications under a common domain. The handlers in each middleware 38 | // attached this way will see a URI with the matched path segment removed. 39 | // 40 | // i.e., path of "/api/member/profile" only passes "/member/profile" to $apiMiddleware 41 | // - $app->pipe('/api', $apiMiddleware); 42 | // - $app->pipe('/docs', $apiDocMiddleware); 43 | // - $app->pipe('/files', $filesMiddleware); 44 | 45 | // Register the routing middleware in the middleware pipeline. 46 | // This middleware registers the Zend\Expressive\Router\RouteResult request attribute. 47 | $app->pipe(RouteMiddleware::class); 48 | 49 | // The following handle routing failures for common conditions: 50 | // - HEAD request but no routes answer that method 51 | // - OPTIONS request but no routes answer that method 52 | // - method not allowed 53 | // Order here matters; the MethodNotAllowedMiddleware should be placed 54 | // after the Implicit*Middleware. 55 | $app->pipe(ImplicitHeadMiddleware::class); 56 | $app->pipe(ImplicitOptionsMiddleware::class); 57 | $app->pipe(MethodNotAllowedMiddleware::class); 58 | 59 | // Seed the UrlHelper with the routing results: 60 | $app->pipe(UrlHelperMiddleware::class); 61 | 62 | // Add more middleware here that needs to introspect the routing results; this 63 | // might include: 64 | // 65 | // - route-based authentication 66 | // - route-based validation 67 | // - etc. 68 | 69 | // Register the dispatch middleware in the middleware pipeline 70 | $app->pipe(DispatchMiddleware::class); 71 | 72 | // At this point, if no Response is returned by any middleware, the 73 | // NotFoundHandler kicks in; alternately, you can provide other fallback 74 | // middleware to execute. 75 | $app->pipe(NotFoundHandler::class); 76 | }; 77 | -------------------------------------------------------------------------------- /expressive/config/routes.php: -------------------------------------------------------------------------------- 1 | get('/', App\Handler\HomePageHandler::class, 'home'); 13 | * $app->post('/album', App\Handler\AlbumCreateHandler::class, 'album.create'); 14 | * $app->put('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.put'); 15 | * $app->patch('/album/:id', App\Handler\AlbumUpdateHandler::class, 'album.patch'); 16 | * $app->delete('/album/:id', App\Handler\AlbumDeleteHandler::class, 'album.delete'); 17 | * 18 | * Or with multiple request methods: 19 | * 20 | * $app->route('/contact', App\Handler\ContactHandler::class, ['GET', 'POST', ...], 'contact'); 21 | * 22 | * Or handling all request methods: 23 | * 24 | * $app->route('/contact', App\Handler\ContactHandler::class)->setName('contact'); 25 | * 26 | * or: 27 | * 28 | * $app->route( 29 | * '/contact', 30 | * App\Handler\ContactHandler::class, 31 | * Zend\Expressive\Router\Route::HTTP_METHOD_ANY, 32 | * 'contact' 33 | * ); 34 | */ 35 | return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void { 36 | $app->get('/', App\Handler\HomePageHandler::class, 'home'); 37 | $app->get('/api/ping', App\Handler\PingHandler::class, 'api.ping'); 38 | }; 39 | -------------------------------------------------------------------------------- /expressive/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !cache 3 | !cache/.gitkeep 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /expressive/data/cache/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alextech/zendframework-tutorial-en/852b62308b446bcdffbf3c68f993afe4a527bd28/expressive/data/cache/.gitkeep -------------------------------------------------------------------------------- /expressive/phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | Expressive Skeleton coding standard 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | src 20 | 21 | -------------------------------------------------------------------------------- /expressive/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | ./test 9 | 10 | 11 | 12 | 13 | 14 | ./src 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /expressive/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | # The following rule allows authentication to work with fast-cgi 3 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 4 | # The following rule tells Apache that if the requested filename 5 | # exists, simply serve it. 6 | RewriteCond %{REQUEST_FILENAME} -s [OR] 7 | RewriteCond %{REQUEST_FILENAME} -l [OR] 8 | RewriteCond %{REQUEST_FILENAME} -d 9 | RewriteRule ^.*$ - [NC,L] 10 | 11 | # The following rewrites all other queries to index.php. The 12 | # condition ensures that if you are using Apache aliases to do 13 | # mass virtual hosting, the base path will be prepended to 14 | # allow proper resolution of the index.php file; it will work 15 | # in non-aliased environments as well, providing a safe, one-size 16 | # fits all solution. 17 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ 18 | RewriteRule ^(.*) - [E=BASE:%1] 19 | RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L] 20 | -------------------------------------------------------------------------------- /expressive/public/index.php: -------------------------------------------------------------------------------- 1 | get(\Zend\Expressive\Application::class); 22 | $factory = $container->get(\Zend\Expressive\MiddlewareFactory::class); 23 | 24 | // Execute programmatic/declarative middleware pipeline and routing 25 | // configuration statements 26 | (require 'config/pipeline.php')($app, $factory, $container); 27 | (require 'config/routes.php')($app, $factory, $container); 28 | 29 | $app->run(); 30 | })(); 31 | -------------------------------------------------------------------------------- /expressive/src/App/ConfigProvider.php: -------------------------------------------------------------------------------- 1 | $this->getDependencies(), 25 | 'templates' => $this->getTemplates(), 26 | ]; 27 | } 28 | 29 | /** 30 | * Returns the container dependencies 31 | */ 32 | public function getDependencies() : array 33 | { 34 | return [ 35 | 'invokables' => [ 36 | Handler\PingHandler::class => Handler\PingHandler::class, 37 | ], 38 | 'factories' => [ 39 | Handler\HomePageHandler::class => Handler\HomePageHandlerFactory::class, 40 | ], 41 | ]; 42 | } 43 | 44 | /** 45 | * Returns the templates configuration 46 | */ 47 | public function getTemplates() : array 48 | { 49 | return [ 50 | 'paths' => [ 51 | 'app' => ['templates/app'], 52 | 'error' => ['templates/error'], 53 | 'layout' => ['templates/layout'], 54 | ], 55 | ]; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /expressive/src/App/Handler/HomePageHandler.php: -------------------------------------------------------------------------------- 1 | router = $router; 32 | $this->template = $template; 33 | $this->containerName = $containerName; 34 | } 35 | 36 | public function handle(ServerRequestInterface $request) : ResponseInterface 37 | { 38 | if (! $this->template) { 39 | return new JsonResponse([ 40 | 'welcome' => 'Congratulations! You have installed the zend-expressive skeleton application.', 41 | 'docsUrl' => 'https://docs.zendframework.com/zend-expressive/', 42 | ]); 43 | } 44 | 45 | $data = []; 46 | 47 | $data['containerName'] = 'Zend Servicemanager'; 48 | $data['containerDocs'] = 'https://docs.zendframework.com/zend-servicemanager/'; 49 | 50 | $data['routerName'] = 'FastRoute'; 51 | $data['routerDocs'] = 'https://github.com/nikic/FastRoute'; 52 | 53 | $data['templateName'] = 'Zend View'; 54 | $data['templateDocs'] = 'https://docs.zendframework.com/zend-view/'; 55 | 56 | return new HtmlResponse($this->template->render('app::home-page', $data)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /expressive/src/App/Handler/HomePageHandlerFactory.php: -------------------------------------------------------------------------------- 1 | get(RouterInterface::class); 17 | $template = $container->has(TemplateRendererInterface::class) 18 | ? $container->get(TemplateRendererInterface::class) 19 | : null; 20 | 21 | return new HomePageHandler($router, $template, get_class($container)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /expressive/src/App/Handler/PingHandler.php: -------------------------------------------------------------------------------- 1 | time()]); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /expressive/templates/error/404.phtml: -------------------------------------------------------------------------------- 1 | headTitle('404 Not Found'); ?> 2 | 3 |

Oops!

4 |

This is awkward.

5 |

We encountered a 404 Not Found error.

6 |

7 | You are looking for something that doesn't exist or may have moved. Check out one of the links on this page 8 | or head back to Home. 9 |

10 | -------------------------------------------------------------------------------- /expressive/templates/error/error.phtml: -------------------------------------------------------------------------------- 1 | headTitle(sprintf('%d %s', $this->status, $this->reason)); ?> 2 | 3 |

Oops!

4 |

This is awkward.

5 |

We encountered a escapeHtml(sprintf('%d %s', $this->status, $this->reason))?> error.

6 | status == 404) : ?> 7 |

8 | You are looking for something that doesn't exist or may have moved. Check out one of the links on this page 9 | or head back to Home. 10 |

11 | 12 | -------------------------------------------------------------------------------- /expressive/templates/layout/default.phtml: -------------------------------------------------------------------------------- 1 | headLink() 3 | ->prependStylesheet('https://use.fontawesome.com/releases/v5.0.6/css/all.css') 4 | ->prependStylesheet('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'); 5 | $this->inlineScript() 6 | ->prependFile('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js') 7 | ->prependFile('https://code.jquery.com/jquery-3.3.1.min.js'); 8 | ?> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | headTitle('zend-expressive')->setSeparator(' - ')->setAutoEscape(false)?> 17 | headMeta()?> 18 | headLink()?> 19 | 25 | 26 | 27 |
28 | 61 |
62 | 63 |
64 |
65 | content?> 66 |
67 |
68 | 69 | 77 | 78 | inlineScript()?> 79 | 80 | 81 | -------------------------------------------------------------------------------- /expressive/test/AppTest/Handler/HomePageHandlerFactoryTest.php: -------------------------------------------------------------------------------- 1 | container = $this->prophesize(ContainerInterface::class); 23 | $router = $this->prophesize(RouterInterface::class); 24 | 25 | $this->container->get(RouterInterface::class)->willReturn($router); 26 | } 27 | 28 | public function testFactoryWithoutTemplate() 29 | { 30 | $factory = new HomePageHandlerFactory(); 31 | $this->container->has(TemplateRendererInterface::class)->willReturn(false); 32 | 33 | $this->assertInstanceOf(HomePageHandlerFactory::class, $factory); 34 | 35 | $homePage = $factory($this->container->reveal()); 36 | 37 | $this->assertInstanceOf(HomePageHandler::class, $homePage); 38 | } 39 | 40 | public function testFactoryWithTemplate() 41 | { 42 | $this->container->has(TemplateRendererInterface::class)->willReturn(true); 43 | $this->container 44 | ->get(TemplateRendererInterface::class) 45 | ->willReturn($this->prophesize(TemplateRendererInterface::class)); 46 | 47 | $factory = new HomePageHandlerFactory(); 48 | 49 | $homePage = $factory($this->container->reveal()); 50 | 51 | $this->assertInstanceOf(HomePageHandler::class, $homePage); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /expressive/test/AppTest/Handler/HomePageHandlerTest.php: -------------------------------------------------------------------------------- 1 | container = $this->prophesize(ContainerInterface::class); 29 | $this->router = $this->prophesize(RouterInterface::class); 30 | } 31 | 32 | public function testReturnsJsonResponseWhenNoTemplateRendererProvided() 33 | { 34 | $homePage = new HomePageHandler( 35 | $this->router->reveal(), 36 | null, 37 | get_class($this->container->reveal()) 38 | ); 39 | $response = $homePage->handle( 40 | $this->prophesize(ServerRequestInterface::class)->reveal() 41 | ); 42 | 43 | $this->assertInstanceOf(JsonResponse::class, $response); 44 | } 45 | 46 | public function testReturnsHtmlResponseWhenTemplateRendererProvided() 47 | { 48 | $renderer = $this->prophesize(TemplateRendererInterface::class); 49 | $renderer 50 | ->render('app::home-page', Argument::type('array')) 51 | ->willReturn(''); 52 | 53 | $homePage = new HomePageHandler( 54 | $this->router->reveal(), 55 | $renderer->reveal(), 56 | get_class($this->container->reveal()) 57 | ); 58 | 59 | $response = $homePage->handle( 60 | $this->prophesize(ServerRequestInterface::class)->reveal() 61 | ); 62 | 63 | $this->assertInstanceOf(HtmlResponse::class, $response); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /expressive/test/AppTest/Handler/PingHandlerTest.php: -------------------------------------------------------------------------------- 1 | handle( 18 | $this->prophesize(ServerRequestInterface::class)->reveal() 19 | ); 20 | 21 | $json = json_decode((string) $response->getBody()); 22 | 23 | $this->assertInstanceOf(JsonResponse::class, $response); 24 | $this->assertTrue(isset($json->ack)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /mvc/.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | ._* 3 | .vagrant 4 | .~lock.* 5 | .buildpath 6 | .DS_Store 7 | .idea 8 | .project 9 | .settings 10 | vendor/ 11 | composer.phar 12 | config/development.config.php 13 | phpunit.xml 14 | -------------------------------------------------------------------------------- /mvc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-apache 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y git zlib1g-dev \ 5 | && docker-php-ext-install zip \ 6 | && a2enmod rewrite \ 7 | && sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/apache2.conf \ 8 | && mv /var/www/html /var/www/public \ 9 | && curl -sS https://getcomposer.org/installer \ 10 | | php -- --install-dir=/usr/local/bin --filename=composer 11 | 12 | WORKDIR /var/www 13 | -------------------------------------------------------------------------------- /mvc/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2015, Zend Technologies USA, Inc. 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | - Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /mvc/README.md: -------------------------------------------------------------------------------- 1 | # Zend Framework Tutorial Repository 2 | 3 | These are sources for tutorials published at [Alex Tech Adventures](http://alex-tech-adventures.com) and 4 | [YouTube](https://www.youtube.com/playlist?list=PLXRC3l-ZhN3rQrtVm9nLe_vRi7AB-iWOX). 5 | The tutorial is derived from original Zend Skeleton application. You can view full original install README file at [Original Repository](https://github.com/zendframework/ZendSkeletonApplication). 6 | 7 | Use branches to explore tutorial milestones. You can checkout any branch to see how the application behaves. 8 | I recommend detailed reading of commit diffs to understand how exactly some concept works, or how to perform a task within the framework. 9 | 10 | If you have any fixes or improvements, you may submit a PR against `devel` branch. 11 | 12 | --- 13 | 14 | Thank you very much for the donation offers! These tutorials are very long to produce. Extra donations 15 | will help towards doing this work sustainably without going on extended breaks. 16 | 17 | [![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PET8HPTAH3BVU) 18 | -------------------------------------------------------------------------------- /mvc/TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | This is a TODO list for the feature/zend-mvc-v3-minimal branch. 4 | 5 | ## Documentation 6 | 7 | - ModuleRouteListener is removed from the skeleton. This won't affect existing 8 | users, but *will* affect experienced users who originally relied on it being 9 | active in new skeleton projects. 10 | - The `/[:controller][/:action]]` route was removed from the skeleton. Again, it 11 | will not affect existing users, but *will* affect experienced users who 12 | originally relied on it being active in new skeleton projects. 13 | -------------------------------------------------------------------------------- /mvc/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | VAGRANTFILE_API_VERSION = '2' 5 | 6 | @script = <