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
Related
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.
We use laravel artisan make commands to create class, model, migration file. Make: auth imports bunch of authentication system files in the project directory.
Is it possible to create html-php template and import them to our project from command line or terminal. How to do it?
Example:
import admin.dashboard - ( Imports custom made admin dashboard with all files)
Artisan does not provides any html/view template and if want you can create an artisan command.
You can do something like this:
Create artisan command
php artisan make:command HtmlCommand
Create stub files(template file) with variable placeholder which will be replaced by artisan command options and generate html from it and save to view.
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.