How to run a command with arguments in Laravel Vapor - laravel

I Just started testing Laravel Vapor, everything working well except I'm using filament package which it needs to run a command to create admin user, the command is working locally on my computer and I have a user now, but in production when I execute the command (./vendor/bin/vapor command production) and then the command that creates the user (php artisan make:filament-user). vapor not giving any input to enter my name and my email address. So is there anyway to give arguments for commands in vapor? or is there anyway to give the these arguments with the command? thank you

simple, just use your command by command line in the console or inside vapor page, menu commands in your project, example:
php artisan <command_name> '<arguments_parameters>'
my job command with argument:
php artisan metric:consolidate '2022-01-29 00:00' (job name with date start argument).

Related

Laravel "php artisan serv" works fine. Please Explain how artisan works

Please note that "php artisan serve" works fine. Also it works with wrong spelling for "serve" as "serv". Previously, Laravel used to hint that "Did you mean php artisan serve" Im not understanding how artisan works now. Please provide some sources to read about this.
This is the screenshot for my question.
"php artisan serve" command is technical a simple Laravel command line command. You are able to create commands to. With the artisan command: php artisan make:command MyCommand` you can create a new commmand. which you can use over your cli.
How it works? I suggest that laravel iterate over some specific folders and read all files which extend the class Illuminate\Console\Command;. Then Laravel put all signature variables in an array.
Afterwards if you enter a command laravel would check the signture array with your input. Larvel would use some logics (maybe similar_text() what #GertB suggested in the comments) to find a command when you dont pass the entire command.
You are welcome to try the following. Create your own command. Enter "serv" in the signature. Then you will notice that you call your command with "php artisan serv" and no longer start the BuildIn server.

Laravel Cron Job not running over ubuntu server

I have a laravel application setup over Ubuntu server using Nginx. Here I have the cron jobs. I was facing an issue, that the server was not automatically picking up changes on Jobs Files. So I googled the things, and found a command from this article which I ran;
php artisan queue:restart
Since I have run this command, now no job is running even. I am also trying with simple HeartbeatJob to log info but it is also not working. When I do php artisan schedule:run,
no error in particular just screen output as:
[2021-09-11T08:41:32+00:00] Running scheduled command: App\Jobs\Heartbeat
But nothing happens. Any idea what this queue command has done wrong and how I make my jobs working again?
Your cron job will need the absolute path to artisan, so should look something like :
php /home/user/site.com/artisan queue:restart
You may also need to specify the queue with :
php /home/user/site.com/artisan queue:restart --queue=nameofqueue

Unable to run migration via artisan command

I have a Laravel 7 project and pushed it to a live server for production but I can't run migration successfully. I always get an error 'access denied' error.
I can confirm that the command sees the .env file and the connection details are all correct. When I ssh into the server and run mysql command using same parameters saved in the .env file, connection is successful. Adding the details into workbench and SequelPro also works so I am not sure why php artisan migrate doesn't work
Run the following command:
php artisan tinker
Tinker is Laravel's own repl.
It will prompt you to enter the commands. Here you can check and print the value of the environment variables by entering string inside env method.
>>> env('DB_DATABASE')
and so on for the other DB parameters.
Hope this helps.
For more help you can check out the official Github repository of tinker:
https://github.com/laravel/tinker

Cronjob setup for laravel 4.2 in cpanel

I am using laravel 4.2. I have created command file for cron job and added it into artisan file. I tested it in command. Everything is working fine in localhost. In Cpanel server I gave command path like,
php /home/fridayburr/public_html/version1/artisan active:user 1>> /dev/null 2>&1
But cron job is not working.
This is how I did in my shared Hosting using CPANEL
Here CRON Task is set on UNIX, to run every minute.
Add the schedule call with appropriate time schedule.
laravel Schedule documentation

CodeIgniter CRON job

I'm trying to set up a CRON job to make some database changes on a CodeIgniter install and having issues with the host that are stopping it from working. The host's CRON setup only allows you to execute a PHP file rather than calling a URL.
What I've tried:
Curl, wget, file_get_contents, fopen, http_get from a static PHP file - all not allowed by the host
/path/to/php /path/to/index.php controller method - to use the command line interface
After unfruitful conversations with the host I'm out of ideas. Does anyone know how I could call a controller method from a static PHP file without the above?
First of all, I'm assuming you are using CI ver 2> (CLI support was not available before).
Secondly, lets say that the page you are trying to fire under cron is http://www.mysite.com/index.php/cronjobs/thejob
The correct command would be:
/usr/bin/php /var/www/rootCIfolder/index.php cronjobs thejob
Replace /usr/bin/php with the location of your php executable and /var/www/rootCIfolder with the location of your CI folder.
You need to have php compiled with command line support. You can verify this by:
# php -v
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21)

Resources