Laravel is a very powerful framework, designed for php web application. It will give you ways to modularize your codes and make it look cleaner and easier to read and understand
mv composer.phar /usr/local/bin/composer
composer global require "laravel/installer"
run laravel
laravel new blog
composer create-project --prefer-dist laravel/laravel blog "5.4.*"
Server Options
- Artisan
- Laravel Homestead
- Docker
- Mamp / Wamp
Artisan is the command-line interface included with Laravel.
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.
A full PHP development environment for Docker.
Laradock - http://laradock.io/
docker-compose up -d nginx mysql redis beanstalkd
docker-compose exec workspace bash
Go to localhost
Controllers
Views
Storage
.env
File with configuration values based on the environment where the application is running.
* Do not commit
All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by the framework.
Route::get('/', function () {
return view('welcome');
});
Route::get('/about', function () {
return '<h1>About Laravel</h1>';
});
Route::get('/about', function () {
return view('welcome.blade.php');
//return view('welcome');
});
Route::group(['prefix' => 'ajax'], function(){
Route::group(['prefix' => 'blog'], function(){
Route::post('blog', 'blogController@Status');
Views contain the HTML served by your application and separate your controller / application logic from your presentation logic.
Stored in the resources/views directory
<html>
<body>
<h1> Hello, World </h1>
</body>
</html>
Route::get('/about', function () {
return view('about', [
'title' => "Intro to Laravel",
]);
});
Route::get('/about', function () {
return view('about')->with('title', 'Intro to Laravel');
});
Route::get('/about', function () {
$title = 'Intro to Laravel';
$group = 'Miami SoFlo PHP';
$sections = ['Set up', 'Laradock', 'Routing', 'Views', 'Controllers'];
return view('about', compact('title', 'group', 'sections'));
// return view('about', [
// 'title' => $title,
// 'group' => $group
// ]);
});
<h1> <?php echo $title; ?> </h1>
<?php
echo "<h5> $group </h5>";
?>
<ul>
<?php foreach( $sections as $section):?>
<li> $section </li>
<?php endforeach; ?>
</ul>
<?php if ($condition): ?>
{ do something }
<?php endif; ?>
<?php foreach ($conditions as $condition) { ?>
{ do something }
<?php } ?>
<div> <?php echo $variable; ?> </div>
<?php require('/layouts/nav_bar.php'); ?>
@if ($condition)
{ do something }
@endif
@foreach($conditions as $condition)
{ do something }
@endforeach
<div> {{variable}} </div>
include('layouts.nav')
Default templating engine provided by Laravel.
<h1> {{ $title }} </h1>
<h5> {{ $group }} </h5>
<ul>
@foreach( $sections as $section)
<li> {{ $section }} </li>
@endforeach
</ul>
<h1> <?php echo $title; ?> </h1>
<?php
echo "<h5> $group </h5>";
?>
<ul>
<?php foreach( $sections as $section):?>
<li> $section </li>
<?php endforeach; ?>
</ul>
@yield
@section
@extends
@include
<!doctype html>
<html>
<head>
<title>Laravel</title>
</head>
<body>
<header>
@include('layout.nav)
</header>
@yield('content')
<footer>
@include('layout.footer)
</footer>
</body>
</html>
Instead of defining all of your request handling logic as Closures in route files, you may wish to organize this behavior using Controller classes. Controllers can group related request handling logic into a single class.
Stored in the app/Http/Controllers.
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AboutPageController extends Controller
{
public function about()
{
// do something
}
}
php artisan make:controller AboutPageController
-------- Routes File ---------
Route::get('/about', 'AboutPageController@about');
------ Controller File -------
class AboutPageController extends Controller
{
//
public function about()
{
$title = 'Intro to Laravel';
$group = 'Miami SoFlo PHP';
$sections = ['Set up', 'Laradock', 'Routing', 'Views', 'Controllers'];
return view('about', compact('title', 'group', 'sections'));
}
}
Laravel Mix provides a fluent API for defining Webpack build steps for your Laravel application using several common CSS and JavaScript pre-processors
Requirements
- Node JS
- NPM
The default package.json file includes everything you need to get started
npm install
npm run dev / production
Laravel Docs - https://laravel.com/docs/5.5
Larachat (slack, podcast) - https://larachat.co/
Laravel New - https://laravel-news.com/
Laracast - https://laracasts.com/
Codecourse - https://www.codecourse.com/
Treehouse - https://teamtreehouse.com/library/q:laravel