I created a custom package following the documentation. (https://laravel.com/docs/5.2/packages#routing)
I added a route in the custom routes file, it appears when checking with "php artisan route:list" but I get NotFoundHttpException.
I used "php artisan route:clear" to clear the routes cache but the issue persists.
If I add the route in the main app routes files works fine.
Service provider:
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__ . '/../database/migrations/' => database_path('migrations')
], 'migrations');
if (! $this->app->routesAreCached()) {
require __DIR__.'/../Http/routes.php';
}
}
Custom routes file:
Route::get('foo', function () {
return 'Hello World';
});
For the informatie you give here i cannot just give a clear answer.
If your package structure is like this
PackageMainDir
- src
- Controllers
- Migrations
- Models
PackageServiceProvider.php
Routes.php
- test
- vendor
composer.json
phpunit.xml
You will have in your PackageServiceProvider.php the following code:
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
$this->publishes([
realpath(__DIR__.'/Migrations') => $this->getDatabasePath().'/migrations',
]);
if (! $this->app->routesAreCached()) {
require_once(__DIR__ . '/Routes.php');
}
}
I hope its not to late and otherwise other user will have the profit of my answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With