I often do something like this:
php artisan route:list
php artisan migrate
php artisan db:seed
Only artisan command name is changed. I know how to get all parameters of previous command except last: !:1- (in my case it gives me artisan). But maybe exist shortcut that gives me command name with all arguments except last (in my case php artisan)? I know I can use alias a="php artisan" for such purpose, but general shortcut for any command will be very useful.
The same trick applies, just change 1 to 0
!:0-
What about a function? I called it rms for route; migrate; seed
rms () { php "$1" "route:list"; php "$1" migrate; php "$1" "db:seed"; }
Related
I have a doubt, I know that to call only laravel commands I have to use the command Artisan::call('command name') but how can I do it if I want to execute the following task
Artisan::call('cat archive | php artisan project:method'); //NOT WORK
cat name_file | php artisan project:method
For example I want to execute the command
CAT /tmp/archive.eml | php artisan command:name_method
Since what I want to do is to read files with cat that are in another directory through a foreach and enter the command that manipulates the data of those files.
I am writing a console command. This command also calls another command.
Basically say: php artisan command:one. So inside command one, I call php artisan command:two.
They both have interactions ($this->info()) stating the progress or state of the current operations. But when I run php artisan command:one I can't see this displayed info from php artisan command:two, though php artisan command:two has its own output info and progress state.
How do I ensure to see the progress and states from php artisan command:two which is called in php artisan command:one?
Using Artisan::call() doesn't redirect called command's output to original command's output.
To call another Artisan command and save its output you should use $this->call() from your command.
from some reason I am unable to save output of artisan command into variable as a string.
What am I doing wrong?
#!/bin/sh
key=$(php artisan key:generate --show)
echo $key
Says stdout is not a tty
Thank you
Are you sure, you are running this script with same folder artisan command ?
You should run this script with same folder with artisan
or you should fix script like this,
#!/bin/sh
key=$(php /projectpath/artisan key:generate --show)
echo $key
I hope this will help you
I am trying to debug my application and I had few log statements using Log facade. For now, I run the application using artisan serve and it will write the log message to the log file and to get a real time log message I run.
tail -f laravel.log
Is there any way I can directly print the log message to the same console/terminal that is running php artisan serve?
You can do this using following. This works anywhere..
$output = new Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln("<info>Error message</info>");
This will print the message in terminal / console that is running php artisan serve
tail -f storage/logs/laravel.log & php artisan serve
Based on #aquasmit answer:
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln("<info>Info message</info>");
Note the added \ before Symfony.
The standard "error_log" PHP function does what you want.
Hello, I am working on app in which i need to use phpmd as php artisan phpmd(i ). means make phpmd as local command and use in project.requirement is when i clone the project no additional things should be required and one can freely run `php artisan phpmd` command.which work same as `phpmd`
command will be like php artisan phpmd <file> <ruleset>
I guess you're already have your Artisan command ready and working. Then best approach will be creating .bat script for Windows and .sh script for Unix systems and placing it in Laravel project's root directory.
For example, phpmd.bat file can look like that:
php artisan phpmd %1 %2
When you'll clone the project, you can just run phpmd someFile someRuleset from Laravel project directory and it should work exactly as php artisan phpmd someFile someRuleset command.
For Ubuntu, Mac and other Unix OS .sh file will look similar:
#!/bin/sh
php artisan phpmd $1 $2