Wednesday, March 29, 2017

[Solved] Fatal error: "There is no suitable CSPRNG installed on your system"

I saw this error when I tried to install Linux (Cent OS) environment to run Laravel 5.3
Here is the fastest solution that I found :)

Edit your php.ini, add ":/dev/urandom:/dev/random" at the end of open_basedir info to allow php can execute into these folders

open_basedir = "/tmp:/u01/ottportal/cms/:/u01/ottportal/env/php/:/dev/urandom:/dev/random"

Tuesday, March 28, 2017

Laravel how to create a custom Artisan Console Command

My project need a report function which run every 30 minutes.
And, here is my solution for this task: Using Artisan Console Command, combine with Linux's crontab.

1. Prepare:
- Set php environment (optional)
- Laravel 5.x
- Allow your account can run "crontab" function

2. Create a custom Console command:   GeneralReport
cd /your/project/path/
php artisan make:command GeneralReportCommand

This command will generate a class with name "GeneralReportCommand" in folder /your/project/path/app/Console/Commands/