项目作者: adrosoftware

项目描述 :
Zend Expressive Routes Loader
高级语言: PHP
项目地址: git://github.com/adrosoftware/zerp-loader.git
创建时间: 2019-08-11T21:13:50Z
项目社区:https://github.com/adrosoftware/zerp-loader

开源协议:

下载


This package is abandoned

Since Zend migrated to be Laminas, now I created a new package for Mezzio

Zend Expressive Routes and Pipeline Loader

Build status
Coverage Status
Latest Stable Version
License

Purpose

When building a medium to large applications on Zend Expressive is better if you can organize your routes. By default expressive define all the routes in the routes.php file under the config directory. For me is better if you can at least organize the routes by modules of routes prefix. For example routes.web.php for all the web routes and routes.api.php for al the api routes.

Usage

  1. $ composer require adrosoftware/zerp-loader

The public/index.php file by default look like this:

  1. <?php
  2. declare(strict_types=1);
  3. // Delegate static file requests back to the PHP built-in webserver
  4. if (PHP_SAPI === 'cli-server' && $_SERVER['SCRIPT_FILENAME'] !== __FILE__) {
  5. return false;
  6. }
  7. chdir(dirname(__DIR__));
  8. require 'vendor/autoload.php';
  9. /**
  10. * Self-called anonymous function that creates its own scope and keep the global namespace clean.
  11. */
  12. (function () {
  13. /** @var \Psr\Container\ContainerInterface $container */
  14. $container = require 'config/container.php';
  15. /** @var \Zend\Expressive\Application $app */
  16. $app = $container->get(\Zend\Expressive\Application::class);
  17. $factory = $container->get(\Zend\Expressive\MiddlewareFactory::class);
  18. // Execute programmatic/declarative middleware pipeline and routing
  19. // configuration statements
  20. (require 'config/pipeline.php')($app, $factory, $container);
  21. (require 'config/routes.php')($app, $factory, $container);
  22. $app->run();
  23. })();

Assuming you have config/routes.web.php and config/routes.api.php and so on, then replace:

  1. (require 'config/routes.php')($app, $factory, $container);

With something like this:

  1. (new \AdroSoftware\Zerp\Loader('config/routes.*.php'))->load($app, $factory, $container);

Authors:

Adro Rocker.