Home » Php » php – Change Model namespace on project creation

php – Change Model namespace on project creation

Posted by: admin February 25, 2020 Leave a comment

Questions:

the way I use laravel is with composer create-project command, in all my projects after ding this I have to make a few changes like changing Model namespace from App folder to App/Models folder in a few places of the codebase, this to me makes more sense. My question is , is there a way I can do these changes automatically so I don’t have to make the changes manually each new project?

Maybe creating an artisan command? or creating the php files from scratch or using stubs?

How to&Answers:

php artisan make:model Models/Task this will do the right thing, if you do not want to repeat this all the time maybe you can have .bashrc alias rather than a new artisan command.

function pamodel () {
    php artisan make:model Model/"$*"
}

pamodel Test will do.