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
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 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
sorry for rookie custom but I want to make my dev experience easier, so I want to create custom command .bat file in order to open multiple tabs and executing a command in each one (For.example php artisan serve, npm run watch...).
What I tried:
C:\Users\GABRIEL\Desktop\custom-command.bat
I created .bat file like this:
cmd.exe && cd C:\xampp\htdocs\kinshiki && php artisan serve
cmd.exe && cd C:\xampp\htdocs\kinshiki&& npm run watch
cmd.exe && cd C:\xampp\htdocs\ishhiki && expo start
But when I execute file I get an error:
"C:\Users\GABRIEL\Desktop\custom-command.bat" command is not recognized as an internal or external
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 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"; }