387 lines
15 KiB
HTML
387 lines
15 KiB
HTML
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||
|
||
<title>Découverte de Laravel</title>
|
||
|
||
<link rel="stylesheet" href="css/reveal.css">
|
||
<link rel="stylesheet" href="css/theme/solarized.css">
|
||
<link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">
|
||
|
||
<!-- Theme used for syntax highlighting of code -->
|
||
<link rel="stylesheet" href="lib/css/zenburn.css">
|
||
|
||
<!-- Printing and PDF exports -->
|
||
<script>
|
||
var link = document.createElement( 'link' );
|
||
link.rel = 'stylesheet';
|
||
link.type = 'text/css';
|
||
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
||
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
||
</script>
|
||
|
||
<style media="screen">
|
||
div.flex-icons {
|
||
width: 60%;
|
||
margin: auto;
|
||
display: flex;
|
||
justify-content: space-around;
|
||
}
|
||
|
||
.flex-icons .fa {
|
||
font-size: 80px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="reveal">
|
||
<div class="slides">
|
||
<section>
|
||
<h3>Découverte de Laravel</h3>
|
||
<h4>Thibaud Dauce</h4>
|
||
<small><a href="https://twitter.com/ThibaudDauce">@ThibaudDauce</a> | <a href="https://thibaud.dauce.fr">https://thibaud.dauce.fr</a></small>
|
||
</section>
|
||
<section>
|
||
<img src="images/quantic-telecom.png" alt="Quantic Telecom" />
|
||
<h4>Co-fondateur de Quantic Telecom</h4>
|
||
<small><a href="https://www.quantic-telecom.net">https://www.quantic-telecom.net</a></small>
|
||
<hr>
|
||
<img src="images/laravel.png" alt="Formations Laravel" />
|
||
<h4>Formations Laravel</h4>
|
||
<small><a href="https://www.formations-laravel.fr">https://www.formations-laravel.fr</a></small>
|
||
</section>
|
||
<section>
|
||
<h3>Laravel par rapport à Symfony</h3>
|
||
<h4 class="fragment">France vs USA</h4>
|
||
</section>
|
||
<section>
|
||
<h3>L'ORM de Symfony</h3>
|
||
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
<?php
|
||
|
||
class User
|
||
{
|
||
/**
|
||
* @ORM\Column(type="integer")
|
||
* @ORM\Id
|
||
* @ORM\GeneratedValue(strategy="AUTO")
|
||
*/
|
||
private $id;
|
||
|
||
/**
|
||
* @ORM\Column(type="string", length=100)
|
||
*/
|
||
private $email;
|
||
|
||
public function getId()
|
||
{
|
||
return $this->id;
|
||
}
|
||
|
||
public function getEmail()
|
||
{
|
||
return $this->email;
|
||
}
|
||
|
||
public function setId($id)
|
||
{
|
||
$this->id = $id;
|
||
}
|
||
|
||
public function setEmail($email)
|
||
{
|
||
$this->email = $email;
|
||
}
|
||
}
|
||
|
||
$em = $this->get('doctrine')->getManager();
|
||
|
||
$product = new User();
|
||
$product->setEmail('thibaud@dauce.fr');
|
||
$em->persist($product);
|
||
$em->flush();
|
||
|
||
$users = $em->getRepository('AppBundle:User')->findAll();
|
||
$user = $em->getRepository('AppBundle:User')->find(1);
|
||
|
||
var_dump($user->getEmail());
|
||
</code></pre>
|
||
</section>
|
||
<section>
|
||
<h3>L'ORM de Laravel</h3>
|
||
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
<?php
|
||
|
||
class User extends Model
|
||
{
|
||
protected $guarded = [];
|
||
// protected $fillable = ['email'];
|
||
}
|
||
|
||
$user = User::create([
|
||
'email' => 'thibaud@dauce.fr',
|
||
]);
|
||
|
||
$users = User::all();
|
||
$user = User::find(1);
|
||
|
||
var_dump($user->email);
|
||
</code></pre>
|
||
</section>
|
||
<section>
|
||
<h3>L'ORM de Laravel</h3>
|
||
|
||
<pre><code data-trim data-noescape>
|
||
<?php
|
||
|
||
use Illuminate\Support\Facades\Schema;
|
||
use Illuminate\Database\Schema\Blueprint;
|
||
use Illuminate\Database\Migrations\Migration;
|
||
|
||
class CreateUsersTable extends Migration
|
||
{
|
||
public function up()
|
||
{
|
||
Schema::create('users', function (Blueprint $table) {
|
||
$table->increments('id');
|
||
$table->string('email')->unique();
|
||
$table->timestamps();
|
||
});
|
||
}
|
||
|
||
public function down() {}
|
||
}
|
||
</code></pre>
|
||
</section>
|
||
<section>
|
||
<h3>Moteur de template</h3>
|
||
<h4 class="fragment">Twig vs Blade</h4>
|
||
</section>
|
||
<section>
|
||
<h3>Twig</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
{% for user in users if user.active %}
|
||
{{ user.email }}
|
||
{% endfor %}
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>Blade</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
@foreach($users as $user)
|
||
@if ($user->isActive())
|
||
{{ $user->email }}
|
||
@endif
|
||
@endforeach
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>Routing et configuration</h3>
|
||
<h4 class="fragment">YAML vs PHP</h4>
|
||
</section>
|
||
<section>
|
||
<h3>YAML</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
homepage:
|
||
path: /
|
||
defaults: { _controller: AppBundle:Home:index }
|
||
userpage:
|
||
path: /users/{username}
|
||
defaults: { _controller: AppBundle:User:show }
|
||
|
||
parameters:
|
||
database_driver: pdo_mysql
|
||
database_host: 127.0.0.1
|
||
database_port: ~
|
||
database_name: symfony
|
||
database_user: root
|
||
database_password: ~
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>PHP</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
Route::get('/', 'HomeController@index')->name('homepage');
|
||
Route::get('/users/{user}', 'UsersController@show')
|
||
->name('userpage');
|
||
|
||
return [
|
||
'driver' => 'mysql',
|
||
'host' => env('DB_HOST', '127.0.0.1'),
|
||
'port' => env('DB_PORT', '3306'),
|
||
'database' => env('DB_DATABASE', 'forge'),
|
||
'username' => env('DB_USERNAME', 'forge'),
|
||
'password' => env('DB_PASSWORD', ''),
|
||
];
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>Formulaires</h3>
|
||
<h4>PHP vs HTML</h4>
|
||
</section>
|
||
<section>
|
||
<h3>PHP</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
$form = $this->createFormBuilder($task)
|
||
->add('email', TextType::class, [
|
||
'label' => "Email"
|
||
])->add('password', PasswordType::class, [
|
||
'label' => "Mot de passe"
|
||
])->add('save', SubmitType::class, [
|
||
'label' => "S'inscrire"
|
||
])->getForm();
|
||
|
||
{{ form_start(form) }}
|
||
{{ form_widget(form) }}
|
||
{{ form_end(form) }}
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>HTML</h3>
|
||
<pre class="fragment"><code data-trim>
|
||
<form action="{{ route('register') }}" method="post">
|
||
{{ csrf_field() }}
|
||
<div class="field">
|
||
<label class="label">Email</label>
|
||
<p class="control">
|
||
<input class="input {{ $errors->has('email') ? 'is-danger' : ''}}"
|
||
name="email"
|
||
type="text"
|
||
value="{{ old('email')}}"
|
||
>
|
||
</p>
|
||
@if ($errors->has('email'))
|
||
<p class="help is-danger">{{ $errors->first('email') }}</p>
|
||
@endif
|
||
</div>
|
||
<div class="field">
|
||
<label class="label">Mot de passe</label>
|
||
<p class="control">
|
||
<input class="input" name="password" type="password">
|
||
</p>
|
||
</div>
|
||
<div class="field">
|
||
<p class="control">
|
||
<button class="button is-primary">S'inscrire</button>
|
||
</p>
|
||
</div>
|
||
</form>
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>Framework de tests</h3>
|
||
<h4 class="fragment">Tests unitaires avec PHPUnit</h4>
|
||
<h4 class="fragment">Tests HTTP intégrés à Laravel</h4>
|
||
<h4 class="fragment">Tests HTML intégrés à Symfony</h4>
|
||
</section>
|
||
<section>
|
||
<h3>Frameworks de test optionnels chez Laravel</h3>
|
||
<h4 class="fragment">Laravel Browser Kit Testing (surcouche à Symfony)</h4>
|
||
<h4 class="fragment">Laravel Dusk (surcouche à Sélénium)</h4>
|
||
</section>
|
||
<section>
|
||
<h3>Injection de dépendances automatique</h3>
|
||
<h4 class="fragment">Configuration en YAML vs PHP</h4>
|
||
</section>
|
||
<section>
|
||
<h3>Mails</h3>
|
||
<h4 class="fragment">Swift_Message vs Mailable</h4>
|
||
</section>
|
||
<section>
|
||
<h3>Swift_Message</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
$message = new \Swift_Message('Bienvenue !')
|
||
->setFrom('thibaud@dauce.fr')
|
||
->setTo($user->getEmail())
|
||
->setBody(
|
||
$this->renderView(
|
||
'Emails/welcome.html.twig',
|
||
array('user' => $user)
|
||
),
|
||
'text/html'
|
||
)->addPart(
|
||
$this->renderView(
|
||
'Emails/welcome.txt.twig',
|
||
array('user' => $user)
|
||
),
|
||
'text/plain'
|
||
);
|
||
|
||
$mailer->send($message);
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>Mailable</h3>
|
||
<pre class="fragment"><code data-trim data-noescape>
|
||
use App\User;
|
||
use Illuminate\Bus\Queueable;
|
||
use Illuminate\Mail\Mailable;
|
||
use Illuminate\Queue\SerializesModels;
|
||
|
||
class Welcome extends Mailable
|
||
{
|
||
use Queueable, SerializesModels;
|
||
|
||
public $user;
|
||
|
||
public function __construct(User $user)
|
||
{
|
||
$this->user = $user;
|
||
}
|
||
|
||
public function build()
|
||
{
|
||
return $this->subject('Bienvenue !')
|
||
->from('thibaud@dauce.fr')
|
||
->markdown('emails.users.welcome');
|
||
}
|
||
}
|
||
|
||
Mail::to($user->email)->send(new Welcome($user));
|
||
</pre></code>
|
||
</section>
|
||
<section>
|
||
<h3>Et bien d'autres différences</h3>
|
||
</section>
|
||
<section>
|
||
<h3>Travaux pratiques</h3>
|
||
<h4 class="fragment">Création d'un Twitter like</h4>
|
||
</section>
|
||
<section>
|
||
<h3>Features</h3>
|
||
<ul>
|
||
<li class="fragment">Inscription des utilisateurs (username, email, password)</li>
|
||
<li class="fragment">Connexion des utilisateurs</li>
|
||
<li class="fragment">Publication d'un statut</li>
|
||
<li class="fragment">Visualisation des statuts des utilisateurs</li>
|
||
<li class="fragment">Possibilité de like un statut</li>
|
||
<li class="fragment">Envoi d'un mail lors d'un like</li>
|
||
<li class="fragment">Tests ?</li>
|
||
<li class="fragment">Utilisation de SASS ?</li>
|
||
<li class="fragment">Utilisation de JavaScript ?</li>
|
||
</ul>
|
||
</section>
|
||
</div>
|
||
</div>
|
||
|
||
<script src="lib/js/head.min.js"></script>
|
||
<script src="js/reveal.js"></script>
|
||
|
||
<script>
|
||
// More info https://github.com/hakimel/reveal.js#configuration
|
||
Reveal.initialize({
|
||
history: true,
|
||
|
||
// More info https://github.com/hakimel/reveal.js#dependencies
|
||
dependencies: [
|
||
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
|
||
]
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|