Code Monkey home page Code Monkey logo

laravel-base's Introduction

Laravel Base (5.1)

Included packages

Installation

# Clone the repo
git clone https://github.com/bstien/laravel-base [project name]

# Pull inn composer-packages
composer install

# Change the app-key
php artisan key:generate

# Review packages.json and either remove or add node packages before you 
# run the following command.
npm install

# If you added new JS-libs or CSS-frameworks add them to gulpfile.js and 
# run the following command to verify that all is well.
gulp

Database

Using MySQL with utf8 as charset and utf8_danish_ci as collation. According to MySQL docs utf8_danish_ci may be used for Norwegian.

I'm creating two separate users, each with different permissions:

  • Application/production
    • select, delete, update, insert
  • Migrations and maintenance
    • select, delete, update, insert, create, alter, drop, index
-- Create database
CREATE DATABASE dbName DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_danish_ci;

-- User for production / application
-- Place username + password in DB_APPLICATION_USERNAME and DB_APPLICATION_PASSWORD
-- in file .env.
GRANT SELECT, DELETE, UPDATE, INSERT ON dbName.* TO 'appuser'@'localhost' \
IDENTIFIED BY 'somepass';

-- User for running migrations
-- Place username + password in DB_MIGRATION_USERNAME and DB_MIGRATION_PASSWORD
-- in file .env.
GRANT SELECT, DELETE, UPDATE, INSERT, CREATE, ALTER, DROP, INDEX \
ON dbName.* TO 'migrationuser'@'localhost' IDENTIFIED BY 'somepass';

After creation, remember to edit .env and set the config for both users, if needed.
Default DB_CONNECTION is application, which means migrations may not be able to run. See section below for more info.

Running migrations

If DB_CONNECTION is set to application, migrations may not be able to run, since we're using the unprivileged application-user. In these cases you can either change the value to migration or simply set the --database parameter when running migrations so we're able to use the privileged migration-user. See example under.

php artisan migrate --database=migration

Useful commands

PS! I've aliased the command php artisan into the simple art.
Place this line in ~/.bashrc:
alias art='php artisan'

Migrations

# Rollback migration, migrate and seed DB.
# Remove --database if DB_CONNECTION is set to migration.
art migrate:refresh --database=migration && art db:seed 

Generate metadata

# Generate metadata with ide-helper
# The last '-N' writes models to a separate file without overwriting the models themselves.
art ide-helper:generate && art ide-helper:meta && art ide-helper:models -N

laravel-base's People

Contributors

bstien avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.