artisan app:name no longer working

Published 3 years ago by zefman

Hey,

I have just installed a fresh version of Laravel 5 with composer and php artisan app:name is no longer working.

I keep receiving a [Illuminate\Filesystem\FileNotFoundException] exception and is appears as though the file: app/Providers/AppServiceProvider.php is missing.

Anyone got any ideas?

Cheers

atorscho

I get this exactly same message. And I would not recommend you to run php artisan inspire. It definitely does not inspire (I got a hu-uge error message and than none of the commands worked after that).

zefman
zefman
3 years ago (12,350 XP)

Yeah the annoying thing is, running app:name has actually adjusted the namespace in my files, now running any other artisan command results in loads of class not found exceptions!

Devon
Devon
3 years ago (57,390 XP)

@atorscho, @zefman

Created #6198 to fix app:name.

As for the error on existing projects. Make sure the bindings in bootstrap/app.php are correct and run composer dump-autoload to clear out any lingering issues.

aardalich

I thought I'd jump in and try my first Laravel5 project this evening and found the same thing before I got anywhere.

Ended up using the changes in https://github.com/laravel/framework/pull/6198 to fix app:name so I could keep going.

Only other thing I've found so far is I've just loaded in way/generators (which brought in 3.0.2) and found that generate:model is using App as the namespace instead of the new one I've assigned, so expect there has to be another update there too.

masonjo

I am new to laravel, but am playing with 5. I created a new project this morning. It has been working. I just did artisan app:name. I got a file does not exist at path error.

Now my app does not work and neither do the artisan commands. I get PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Console\Kernel does not exist' in ...

I tried composer dump-autoload - no help

I also tried composer update. Nothing updated (I am guessing it is because I just installed earlier today). but then I got an the same error about the Uncaught exception.

I see the comment about the change (6198) above, but I am not sure if this is in what I downloaded today or even if this is a good idea.

Devon
Devon
3 years ago (57,390 XP)

@masonjo, No, the changes have not yet been commit and the bug still exists.

To fix your existing app, you need to make sure the bindings in bootstrap/app.php are correct and run composer dump-autoload to clear out any lingering issues. If it still doesn't work, delete storage/framework/compiled.php and try again.

masonjo

Thanks for the quick reply.

My bootstrap/app.php looks pretty simple.

composer dump-autoload - returns just Generating autoload files

I do not see a compiled.php in storage/framework

My composer.json file still has: "psr-4": { "App\": "app/" }

But my controllers and a couple others I looked at have a namespace with the name I was trying to use with the app:name command.

Also, in the composer.json, should I change this: "config": { "preferred-install": "dist" }

So the I am using a dev-develop?

Devon
Devon
3 years ago (57,390 XP)

You'll need to update your composer.json to have the namespace that your controllers and stuff have. Afterwards, run composer dump-autoload again and see where that gets you.

Leave the rest of your composer.json as it is unless you're wanting to pull in other packages.

masonjo

@devon

Here is what I did to fix it.

In my ide I did a global search and replace ptr\ (this was my new app name) and replaced it with App\

I also did a composer dump-autoload - just for good measure

I did not update the composer.json

So basically I rolled back to the default App namespace. Which is fine for just messing around and learning.

I am assuming that your fixes will help with the artisan app:name command in the future.

Thanks again

gildniy
gildniy
2 years ago (130,155 XP)

For this, me I used a dump-autoload too, and after I repeat an "artisan app:name Foo" and it changed well!

khaledSMQ

Need to Clean config file in bootstrap folder.

LaravelAPP/bootstrap/cache/

by removing all files from this folder you will clear all config cache files.

JamesTheCode

I too used example app:name "php artisan app:name Horsefly" in my case the solution was in finding all files and replace this string with the namespace

IN my root direcotry

grep --null -lr "Horsefly" | xargs --null sed -i 's/Horsefly/App/g'

Find all occurences of "Horsefly" and then replace them with "App"

Please sign in or create an account to participate in this conversation.