Laravel
Getting started with Laravel
#Laravel >= 5.4.*
Getting started with Laravel
Tips: The "$" symbol is a terminal command.
#Starting new project:
$ composer create-project laravel/laravel project-name "5.4.*"
#Executing project:
$ php artisan serve
#Executing project with open ports (for others access):
$ php artisan serve --host 0.0.0.0 --port 8000
*Now a new device in same network can connect to dev computer by ip address of the dev computer.
#Documentation:
*PS: If Laravel Commando dont work, go to below tips:
nano /.bash_profile
And paste
export PATH=/.composer/vendor/bin:$PATH
Restart the terminal and enjoy ;)
#Create Auth (login + register):
$ php artisan make:auth
#Create Table Session:
$ php artisan session:table
#Troubleshooting: LARAVEL 5.4 - Erro SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
Solution: Go to: app/Providers/AppServiceProvider.php and insert:
namespace App\Providers;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
public function boot()
{
Schema::defaultStringLength(191);
}
*Remove (hard) the table users created and run the migrate command:
$ php artisan migrate
#Troubleshooting: ERROR 1005 / 150 constraint:
Generally, this error occurs when you are trying to create a new table, with a reference in an already existing table. Make sure the old table is InnoDB (the 2 must be InnoDB), if you do not change Make sure the collations are the same (utf8, etc ...) SHOW TABLE STATUS WHERE NAME = 'users'; Make sure the old ID field is unsigned (if it is not, in laravel just create it as integer () Reset the tables and rotate again.
#Custom Helpers in Laravel:
- Create the Helpers directory in /app
- Create the customHelper.php in Helpers directory
- Into customHelper.php, insert the code like this: