district5 / php-slim-framework-routes-builder
读取和生成基于包含它们的目录的路由文件。
1.0.2
2022-01-13 10:59 UTC
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2024-09-13 16:51:12 UTC
README
信息
此库自动为Slim Framework应用程序创建app/bootstrap.php
文件。这由$scanAndWrite
参数在开发和生产中控制。
如果$scanAndWrite
参数为true
,这将重新扫描路由目录(或多个目录)并自动生成引导文件。如果为false
,库将直接返回引导文件的路径。
用法...
在您的主public/index.php
或您当前包含路由文件的任何地方,放置以下代码
<?php define('BASE_DIR', realpath(__DIR__ . '/../')); $shouldRescan = true; // You could use a 'development' flag to establish this $routeFile = \District5\SlimRouteFileBuilder\RouteBuilder::scanRoutes( $shouldRescan, // Should the system rescan and write a new routes file? BASE_DIR, // The base directory to work with. '-route.php' // What the route file names should end in (optional). Use null to ignore this. ); /** @noinspection PhpIncludeInspection */ include $routeFile;