@vincej your first issue is putting me in the same category of @bashy and @bestmomo , I wish ... lol
So I can kind of replicate the problem. It is definitely a compile problem, but cannot pickup exactly where. It is a compile sequence generation problem with services.json and classmap.php.
Here is the issue:
- If I run php artisan optimize it will regen autoload_classmap.php iand break something in the Service Provider load sequence.
- Example, In my case I'm unable to load my translator view composer using register in my ServiceProvider, but pretty much all of them fail silently i.e. no error in php artisan commands or compose diag.
- You can delete services.json and classmap.php and try to regen, but it will keep failing. I think it has something to do with view render as you can get it work work if all you is return a string in class e.g. return “nolros”; will work, but as soon as you attempt to load a blade file it fails.
- The solution is to get the app up and running so it can update the 2 files. In my case I did the following:
4.1 load up a blade that uses my TranslatorDecorator.php but find any ServiceProvider that will touch the services.json and classmap.php
4.2 I then comment out all logic in the TranslatorDecorator, but add in a boot() method with a very basic command, in my case the boot below.
4.3 I then load the view again which forces an update on services.json and classmap.php and after that I can return all my code to normal and everything works fine as long as I don’t run php artisan optimize
EDIT:
Ok, the problem is service.json
If I do a file comparison I can see that the php artisan command lines are building the file incorrectly. Too much too put into this message but it is not eager loading certain ServiceProviders, but moving them to deferred which is a problem. So when you touch the file through app code it builds it the right way. In my case it loading the decorator into defer and removing the translator class so the decorator becomes the root class.
// I can then remove all of this after the touch
public function boot()
{
View::composer('auth.register.start', TranslatorComposer::class);
}
My normal register , below, will fail until I touch the files.
private function registerAuthComposer()
{
$this->app->make('view')->composer('auth.register.start', TranslatorComposer::class );
$this->app->make('view')->composer('auth.login', TranslatorComposer::class );
}