I've been stuck with this for a few weeks now, please help.
I'm trying to build a package which contains a admin backend and public front end. depends on domain for routing.
php artisan workbench vendor/package --resources
Route::group([
'domain' => 'admin'
],function()
{
Route::controller('admin', 'Vendor\Package\AdminController');
});
...
'Vendor\Package\AdminServiceProvider'
...
And the ServiceProvider registered:
...
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
$this->app['admin'] = $this->app->share(function ($app)
{
return new AdminController();
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('admin');
}
...
I receive a
ReflectionException
Class Vendor\Package\AdminController does not exist
Any ideas?
Thanks in advance.
Make sure you've namespaced the AdminController file as you have written in your route, and don't forget to dump the autoloader with
php artisan dump-auto
Let us know if you've already done this.
Thank you jlaswell,
I did
php artisan dump-auto
And it shows:
{"error":{"type":"ReflectionException","message":"Class Vendor\\Package\\AdminController does not exist","file":"\/laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerInspector.php","line":28}}
The thing is, my controller is:
- workbench
- vendor
- package
- src
- controllers
- AdminController.php
- vendor
- package
- AdminServiceProvider.php
Is it the path configuration?
Yep, it's just the paths. Folder structure for a workbench package should be as follows.
- workbench
- vendor
- package
- src
- Vendor
- Package
- AdminServiceProvider.php
- AdminController.php
You can also move AdminController.php to it's own controllers folder if you namespace it accordingly!
<?php Vendor/Package/Controllers;
- workbench
- vendor
- package
- src
- Vendor
- Package
- AdminServiceProvider.php
- Controllers
- AdminController.php
Thanks again, it worked.
Then I was trying to replicate the folder structure here: https://github.com/FrozenNode/Laravel-Administrator/tree/master/src
Where controllers are separated from ServiceProvider, wondering if there's anything specific about the structure here. You see, when I tried FrozenNode's structure the 'not-found' error appears.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community