Is it possible to run some other arrtisan command when we run php artisan serve . at the same time ? Is there any way to do that?
You can run multiple commands separated by a semi-colon.
For example:
php artisan view:clear; php artisan route:clear; php artisan cache:clear; php artisan config:clear
Would that help?
You need to setup supervisor on the server. It will start the queue:work for you. It can also run multiple executions of same commands.
Related
I have create a simple bash script for my laravel project (file name: bash-script.sh)
php artisan serv
php artisan queue:work --queue=first_queue
php artisan queue:work --queue=second_queue
php artisan queue:work --queue=third_queue
php artisan queue:work --queue=fourth_queue
php artisan schedule:work
the problem is I want each line of these commands to run in separate terminals.
Maybe this can help you, in the same terminal all processes responses:
php artisan serv &
php artisan queue:work --queue=first_queue &
php artisan queue:work --queue=second_queue &
php artisan queue:work --queue=third_queue &
php artisan queue:work --queue=fourth_queue &
php artisan schedule:work
The ampersand (&) it's for executing in another process and freeing the current execution, all outputs in every processes will write on the same terminal
Or if you do not have a graphic environment on the host (ie you connect to the remote host via ssh) you need a terminal multiplexer like screen or tmux
For both, there are several howto and example all over the web
If you want them to run in a terminal window, you will have to start a terminal window.
xterm -e "php artisan serv"&
xterm -e "php artisan queue:work --queue=first_queue"&
xterm -e "php artisan queue:work --queue=second_queue"&
# et cetera
I have a Laravel project (v8.12) running on PHP 7.4.3 in a dedicated AWS instance with Ubuntu 20.04. When I try to read an environment variable from inside a job, the value is always null, but it works elsewhere. I tried to switch from supervisord to sync driver, still couldn't reach it.
Your problem could be from cache .
you can below commands for remove cache .
php artisan cache:clear
php artisan config:clear
php artisan view:clear
Run below commands
composer dump-autoload
php artisan clear-compiled
php artisan optimize
php artisan route:clear
php artisan view:clear
php artisan cache:clear
php artisan config:cache
php artisan config:clear
For Example
In your env file
SITE_NAME="My website"
Get your env variable like
$data = env('SITE_NAME');
echo $data;
Laravel doesn't read config in env, so env('APP_KEY') always returns NULL. I also use:
php artisan config:clear
and
php artisan config:cache
but it doesn't have any effect. Do you have any solutions to fix? First time, I could fix by using 2 command above, but now I can't.
Try:
php artisan config:clear
then:
php artisan cache:clear
and make sure that you have permissions to run these commands, or you can simply run them with sudo.
I have created some Command files into my Laravel Application. Laravel version is 5.2. I set command like: get:email in the Command file. Also call the Command file into Kernel.php. After that I can see the artisan command list by typing the command php artisan list. as like as below:
//output
get:email
And I changed the command title get:email to get-bq:email. When I run the command php artisan get-bq:email -- its working nicely. Also I can see the list by typing the command php artisan list::
//output
get-bq:email
Issue / Problem: Both commands are working. But I won't to work with both of them. I have done the following things:
modified command file as well as command
run composer dump-autoload -o
run composer update
remove vendor and storage folder then run composer update again.
Still the old command is working into my system.
What I want: How May I remove my old commands from my Laravel(5.2) application?
Run these commands:
php artisan cache:clear
php artisan config:clear
These commands will clear app cache and config cache and recreate it.
I've had the same problem recently.
Repoeatedly tried
php artisan cache:clear
php artisan config:clear
and the cached Kernal command wouldn't clear.
In desperation i killed the queue worker terminal and restarted the queue with the command
php artisan queue:work
The issue stopped.
When I migrate the table, the php artisan migrate does not work.
Use composer.
Navigate to the root directory of the project. Run,
php artisan october:up
if you want to roalback you can run
php artisan october:down
Be sure to use composer in the project directory
php artisan migrate:refresh php artisan migrate:rollback php artisan migrate --force are some cmd's you could try. I don't know if this helps you otherwise please explain your question a bit more.
Go to the root directory of your project in command prompt and run these commands
To reset the current migrations if there are some php artisan migrate:reset
then run php artisan migrate