Support the ongoing development of Laravel.io →
Configuration IOC Architecture

I'm using Laravel 4.2. I have a custom ServiceProvider that is registered in app.php. My code wasn't working the way I expected, so I added a syntax error to my service provider file to see if it was loading.

Turns out, it's not loading when I access my site via the web - the syntax error never gets thrown. But if I run a phpunit test, phpunit experiences the syntax error. Yes, I've run composer dump-auto.

What am I missing? I'm not getting a "can't find file" error - I'm not getting any errors at all, which mean it's not loading the file.

The ServiceProvider is located at /app/providers/myorg/MyOrgServiceProvider.php.

/vendor/composer/autoload_classmap.php is also showing it correctly: 'MyOrg\\ServiceProvider\\MyOrgServiceProvider' => $baseDir . '/app/providers/myorg/MyOrgServiceProvider.php',

//composer.json
"autoload": {
		"classmap": [
			//...all the other autoload files,
			"app/providers"
		]
	},
// /config/app.php
'providers' => array(
					'MyOrg\ServiceProvider\MyOrgServiceProvider',
					'Illuminate\Foundation\Providers\ArtisanServiceProvider',
					'Illuminate\Auth\AuthServiceProvider',
					//....all the other providers
					) 
///app/providers/myorg/MyOrgServiceProvider.php
namespace MyOrg\ServiceProvider;
 
use Illuminate\Support\ServiceProvider;
asdf //the forced syntax error
class MyOrgServiceProvider extends ServiceProvider {
 
  public function register() {
		//...all the binding info     
	}
}
Last updated 3 years ago.
0

Could be a bad meta-data cache, try artisan clear-compiled or you can just delete the file storage/meta/services.json, or change the order of the providers array and it will update the cache on the next run.

Last updated 3 years ago.
0

TerrePorter said:

Could be a bad meta-data cache, try artisan clear-compiled or you can just delete the file storage/meta/services.json, or change the order of the providers array and it will update the cache on the next run.

Tried artisan clear-compiled and tried deleting the storage/meta/services.json file - neither one worked. The services.json file wouldn't put my custom service provider in.

Putt the service provider in at the bottom of the providers instead of the top did work, thanks!

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

tlshaheen tlshaheen Joined 14 Oct 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.