Skip to content

Instantly share code, notes, and snippets.

@bobbybouwmann
Last active October 7, 2020 07:53
Show Gist options
  • Save bobbybouwmann/06bc242188cbd6db34463112e7522655 to your computer and use it in GitHub Desktop.
Save bobbybouwmann/06bc242188cbd6db34463112e7522655 to your computer and use it in GitHub Desktop.

Install Laravel

First steps, setup your project!

Composer

composer create-project --prefer-dist laravel/laravel <project-name>

Laravel installer

laravel new <project-name>

Quick webservers

Laravel offers multiple ways of setting up a webserver very quickly. For the blazing fast setup you can pick php artisan serve. If you don't use queues and so on, Valet is a really good alternative. If you need more framework power like queues homestead is the way to go.

Command line

php artisan serve

Valet

https://laravel.com/docs/5.8/valet

Homestead

https://laravel.com/docs/5.8/homestead


Laravel Debugbar

To see what is happening in your application, but also to debug the debugbar is an essential tool while developing in Laravel

https://github.com/barryvdh/laravel-debugbar

composer require barryvdh/laravel-debugbar --dev

Laravel Telescope

The debugbar is really useful, however Telescope might even give you more information. You can easily add this to your project and right away see what's going on in your application.

https://laravel.com/docs/5.8/telescope

composer require laravel/telescope

Make commands

Laravel offers a lot of command to scaffold classes for you. Use them in your own advantage.

make:auth            Scaffold basic login and registration views and routes
make:channel         Create a new channel class
make:command         Create a new Artisan command
make:controller      Create a new controller class
make:event           Create a new event class
make:exception       Create a new custom exception class
make:factory         Create a new model factory
make:job             Create a new job class
make:listener        Create a new event listener class
make:mail            Create a new email class
make:middleware      Create a new middleware class
make:migration       Create a new migration file
make:model           Create a new Eloquent model class
make:notification    Create a new notification class
make:observer        Create a new observer class
make:policy          Create a new policy class
make:provider        Create a new service provider class
make:request         Create a new form request class
make:resource        Create a new resource
make:rule            Create a new validation rule
make:seeder          Create a new seeder class
make:test            Create a new test class

Generating models

Generating models is probably one of the first things you do. However Laravel can help you generate the other files like migrations, controllers and factories as well. Below are some useful examples

Model, Migration

php artisan make:model Video --controller --migration

php artisan make:model Video -cm

Model, Factory, Migration, Controller

php artisan make:model Video --all

Generating controllers

Next to just generating models with controllers we can also generate specific controllers with extra information. Below you can see some examples:

General

php artisan make:controller --model=Video VideoController

php artisan make:controller --invokable CreateVideoController

Resource

php artisan make:controller --model=Video --resource VideoController

API

php artisan make:controller --model=Video --api VideoController

Authentication

Scaffold the default Laravel authentication. You get register, login and password resets out of the box.

php artisan make:auth

Laravel PipeDream

This an awesome tool that helps you generate all the files you need without having to type out everything yourself. Just install this package and go to http://localhost:8000/pipe-dream and generate everything you need.

https://github.com/pipe-dream/laravel

composer require --dev pipe-dream/laravel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment