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
Related
I have setup a cron job to execute hello.sh
if I echo the current directory from the script using echo $PWD it
output /home/u341967117
echo $PWD
#output /home/u341967117
#and I can not run artisan command here since the Laravel installation for is /home/u341967117/domains/unieschools.com/public_html/ngit
so I try to change the directory before running the php artisan command
\#!/bin/bash
cd /domains/unieschools.com/public_html/ngit
echo $PWD
#php artisan command comes here
But output of the cron job executing the script is throwing error
No such file or directory
I tried changing the working directory to point to the laravel project folder but it keeps throwing error that no such directory exist
you can user this in you file:
PHP=`which php`
$PHP artisan optimize:clear
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.
i'm using bitbucket pipeline to deploy and run some artisan command,
but there is a problem that make me headache, when artisan command failed, envoy show the error/Exception, but not continue to run next envoy task.it's keep show me the exception till i kill the php process in vps server (using kill/pkill command)
here is my envoy
#task('start_check_log', ['on' => 'web'])
cd /home/deployer/mywork/laravel/
nohup bash -c "php artisan serve --env=dusk.local 2>&1 &" && sleep 2
curl -vk http://localhost:8000 &
php artisan check_log
sudo kill $(sudo lsof -t -i:8000)
php artisan cache:clear
php artisan config:clear
#endtask
php artisan check_log just to check the log file, i want to check if error occurred, but when error comes up, envoy stuck on that error.
I've resolved this problem, this is just my stupid, I 've to add command pipe in other to envoy continue the task php artisan check_log && sleep 2 and the envoy continue the process
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"; }
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