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?
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.
Related
When you run php artisan make:component Foo it will always be created inside (root)/resources/views/component.
How can I specify its "parent directory" or any specific directory outside resources folder?
I mean, like creating it at (root)/custom-package/components.
Is there any existing options does make:component command has? or I'm thinking few ways how to achieve this:
Create a custom command that will create the php and blade files to the directory I want.
Create a new command and extend the Laravel's make:component command to modify its path. (Currently, I can't find yet the Class where I can extend it.)
Or is there a config where I can set it?
maybe you can use:
php artisan make:component Foo --path=your/custom/location
hope this help
I installed Laravel (in W10/Wamp3.3/PHP5.6) using Composer and created a new project with the following command:
laravel new my_project
Project doesn't have a welcome page, opens file-list directly. So I decided to try my chance on creating a new controller and create a route.
php artisan make:controller Hello
And my route in routes/web
Route::get('/hello', 'HelloController#index');
I also cleared the route cache:
php artisan route:clear
Created the controller with no methods. myproject/hello shows nothing.
What am I missing? File permissions or wamp based problem?
There's a question related with this but it's more like a server problem.
Few causes for this that I've run into. Most likely one is going to be the server pointing to the incorrect directory. What I would do to test is run php artisan serve from the root of the project. This will open up a server pointing to public directory. If this functions correctly then you have confirmation.
I'm making a migration in laravel like this:
php artisan make:migration create_tasks_table
and then I get a message from the console like this:
Created Migration: 2017_04_03_002411_create_tasks_table
But when I go to the 'database\migrations' directory there's no .php file related to the migration I made.
Why is this happening?
It could be that your IDE is not updating the filesystem. What i would suggest is to use the terminal to navigate to the migrations directory and list the content of the directory to see if its truely empty.
I am working with laravel and I have installed a package using composer by running this command composer require mailchimp/mailchimp=~2.0.
After that I got a folder 'mailchimp' in the vendor directory. In there, there is a file named Mailchimp.php that I have to modify, but based on some old posts here, if I modify the file, any time I run the command composer update, I will loose my changes in the file, just because it is located in the vendor directory. So is there any option for me to solve this problem ?
I tried using the command php artisan vendor:publish but I do not get the expected results.
You can create a custom class which will extend the Mailchimp class and override the function you want. Then use the custom class in your code.
use DrewM\MailChimp\MailChimp;
class CustomMailChimp extends MailChimp {
...
// The function you would like to override
}
Then use it new CustomMailChimp(..)
I want to create a model in a custom path. If i write the php artisan command like the following it will create model inside app.
php artisan make:model core
But i want to create the model file inside the custom made Models folder. How can i do it ?
Just define the path where you want to create model.
php artisan make:model <directory_name>/<model_name>
e.g.
php artisan make:model Models/core
You can do it easily with custom directory of your Models Folder (I assume Models Folder is sub folder of App).
Just use this command php artisan make:model Models/core then you will get your desire result.
Thanks.