Category Archives: Bash

Laravel 4.2 Set up Cron for Laravel Artisan Command

Brief instructions to setup a Cron job on Ubuntu for a Laravel PHP Artisan Command.

Create a Crontab for the vagrant user
$ sudo crontab -u vagrant -e

Add the following lines:

#test the cron every minute
*/1 * * * * /usr/bin/php /vagrant/ahvla-beta/artisan command:login-access –status=enable –disable-confirm=1 –disable-log=1

#test that the cron is running without PHP dependancy
*/1 * * * * echo “$(date)” >> /vagrant/project-root/cron-contents.txt

Save the file.

Check the contents

$  crontab -l

 

 

Bash Aliases for Laravel

Typing $ php artisan is getting tiresome. So how to create an alias in Bash on the Mac:

Edit ~/user/.bash_profile

//Add the line:
alias pa=”php artisan”
// pa is my chosen alias

// Add an alias to the project directory while we’re here:
// progexample is the alias name for the example project
alias projexample=’cd /Applications/XAMPP/xamppfiles/htdocs/example.com/’

Save and reload the profile from it’s directory location in the terminal:
$ . .bash_profile

Now, $pa migrate is the same as $ php artistan migrate

And to jump straight to the specific project directory it’s: $ projexample

Create Aliases for Aritsan

$ alias g:m=”php artisan generate:migration”

$ g:m create_orders_table –fields=”title:string, description:text:nullable”

Here are some Laravel Bash Aliases