Skip to content

Instantly share code, notes, and snippets.

@veeeeeeeeeee
Last active April 10, 2018 05:06
Show Gist options
  • Save veeeeeeeeeee/bad954033de0c309769d04c63e71d7c0 to your computer and use it in GitHub Desktop.
Save veeeeeeeeeee/bad954033de0c309769d04c63e71d7c0 to your computer and use it in GitHub Desktop.
New Laravel
- create folder Helpers under app\
- create new class Helper {}
- include inside config\app.php
'Helper' => App\Helpers\Helper::class,
- usage:
use Helper;
$h = new Helper();
$h->stuff();
- create new file Helpers\helpers.php
- add path into "autoload" inside composer.json
- composer dump-autoload
-
- create mysql: table
- create artisan: migration, timestamps()
- create mysql: constraint, foreign key, allow null
- create artisan: model, relationships
- create artisan: controller
- modify laravel: routes
- modify laravel: controllers (show, index, create, edit)
- create dir: views (show, index, create, edit)
- modify laravel: controllers (store, update)
- when extending middleware (guard & provider), register in Kernel -> $midddlewareGroups, replicate 'web' if using custom driver
- LoginController overrides methods in Illuminate\Foundation\Auth\AuthenticatesUsers; attemptLogin controls credential-checking logic
- Model needs to extends Illuminate\Foundation\Auth\User or Illuminate\Contracts\Auth\Authenticatable
- Kernel needs to register web's session classes into 'auth' (if using custom driver)
- AuthServiceProvider->boot needs to register provider and extend driver (configured in config/auth.php)
- CustomGuard needs to implements Illuminate\Contracts\Auth\Guard, including authenticate() function (can be found in side Illuminate\Auth\GuardHelpers), use validate()
- CustomUserProvider needs to implement retrieveByCredentials to perform creds check, and validateCredentials to verify integrity of creds
- config/app.php needs to add custom classes to autoload
-
.env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment