Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the default App namespace to something else

I'm about to start a new project and I've decided to go with sf4. So first I've created a new sf project composer create-project symfony/skeleton

But this time I want to get rid of the default App namespace and change it to a specific, project related namespace. But I'm not really sure how to do this. I've tried to edit the psr autoload in the composer.json and run composer dump-autoload but I'm getting this error

PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "Kernel" from namespace "App".

I hope someone can help me.

Greets

like image 490
Larusso Avatar asked Feb 28 '18 20:02

Larusso


People also ask

How do I change the default namespace in C#?

Assuming this is for a C# project and assuming that you want to change the default namespace, you need to go to Project Properties, Application tab, and specify "Default Namespace". Default namespace is the namespace that Visual studio sets when you create a new class.

How do you change your namespace?

Place your cursor in the namespace name. Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Change namespace to <folder name>.

How do I change the default namespace in Visual Studio?

You can change the default namespace, and the assembly name, independently of the name of the project using the project's property pages. If you are using Visual Studio 2003, right-click the project's name in the Solution Explorer and choose "Properties" from the context-sensitive menu that appears.


1 Answers

When working with a framework, you have to learn to go with it's conventions and not against it. Messing with the core files is a terrible idea as it will make upgrades really complicated. Also, frameworks are there to facilitate team work on a project, if you start of by making your own naming conventions you are breaking this.

If you need to have reusable components across multiple projects, Symfony handles that already: https://symfony.com/doc/current/bundles/best_practices.html

like image 82
Magnesium Avatar answered Oct 11 '22 13:10

Magnesium