Support the ongoing development of Laravel.io →
posted 11 years ago
Packages

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.

  1. creates default workbench folders
php artisan workbench vendor/package --resources
  1. Added domain dependent routing to routes.php - it's suppose to be a CMS package:
Route::group([
	'domain' => 'admin'
],function()
{
	Route::controller('admin', 'Vendor\Package\AdminController');
});
  1. Register app.php with ServiceProvider:
...
'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');
	}
...
  1. Under /workbench/vendor/package/src/controllers/, added AdminController and BaseController.

I receive a

ReflectionException
Class Vendor\Package\AdminController does not exist

Any ideas?

Thanks in advance.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

fzhan fzhan Joined 4 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.