Skip to content

ertuo-php/builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ertuo Builders

You can use the "builders" to create the PHP code for the route declaration. The builders are using as input arrays that are created from ExportInterface::toArray().

use Ertuo\Route;
use Ertuo\Builder\BuilderWithArrays;

$routes = Route::add('_app')->...

$php = (new BuilderWithArrays)->buildTree( $routes->toArray() );
file_put_contents('/somewhere/where/routes/live/routes.php', $php);

There are so far several builders:

  • BuilderWithArrays uses arrays to declare nested routes when using Route::group()
  • BuilderWithGenerators is almost the same, but uses yield syntax and generators with Route::group()
  • BuilderOfUnfoldedRoutes instead uses UnfoldedRoute

The generated code from BuilderWithArrays for the route tree looks something like this:

use Ertuo\Route;

return $routes = Route::add('_app', [])
->rule('enum', ['api', 'admin', ], [])->default('web', [])
->group(function()
{
    return array(

        '' => Route::add('_locale', [])
        ->rule('enum', ['en', 'de', ], [])->default('en', [])
        ->group(function()
        {
            return array( ... );
	})
    );
});	 

About

Ertuo Builder: Make everything into Ertuo Routes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages