-
Create .env by running
vi .env
if you already have vi or vim installed, then:-
Copy from the sample from .env.sample
-
Modify the database configuration to your database connection
-
Add Stripe Keys if payment is needed
-
-
Install packages and dependencies:
composer install
If you don't have composer installed, check here.
And then install npm dependencies by running:
npm install
If you don't have npm installed, please check here.
Sometimes, delete
node_modules
,vendor
,package-lock.json
andcomposer.lock
before install. -
Create API_KEY by running:
php artisan key:generate
-
Migrate the database:
php artisan migrate
-
Start the app and see the application in http://127.0.0.1:8000:
php artisan serve
Or use valet, a virtual host, to run in custom domain, eg: myproject.dev
-
Create dummy data:
php artisan db:refresh
-
Queue email tasks:
-
Change the
QUEUE_DRIVE
setting in .env fileQUEUE_DRIVER=database
-
Modify the mail settings in .env file, the example is using gmail:
MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=Example@gmail.com MAIL_PASSWORD=example MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=example@gmail.com MAIL_FROM_NAME="GCC Central Hub"
Remember for APP_NAME or MAIL_FROM_NAME in .env, include the " " to the name you gave.
-
Run
queue listen
orqueue work
php artisan work php artisan work --tries=4 // with max attempts of four
-
-
Invitation token schedulling refresh:
-
Server development (Linux or Homestead), In order to run schedule properly every given timeframe, execute:
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
-
Mac Development Environment, In order to run schedule properly every given timeframe, open a new tab with same root directory of the project and run:
while true; do php artisan schedule:run; sleep 60; done
-
-
Create a Procfile file and add two lines to allocate dynos:
web: vendor/bin/heroku-php-apache2 public/ queue: php artisan queue:work --tries=3 --daemon
web used for indicating where to serve the application. queue is used to allocate a queue to send email tasks.
-
Install ClearDB addon.
The Addon can be installed either from cli or dashboard panel.
-
Add ClearDB config at the start of
config/database.php
in Laravel:<? php // Production on Heroku configs $url = parse_url(getenv("CLEARDB_DATABASE_URL")); $host = $url["host"]; $username = $url["user"]; $password = $url["pass"]; $database = substr($url["path"], 1);
-
Replace the default mysql connection in
config/database.php
with the followings:'mysql' => [ 'driver' => 'mysql', 'host' => $host, 'database' => $database, 'username' => $username, 'password' => $password, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, ],
-
Run in production mode (if deployed in heroku directly using github repo), so run:
npm run prod
Also, set config var
APP_ENV
to production in heroku dashboard panel or using cli.