laravel step 0 (introduction)
TRANSCRIPT
![Page 1: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/1.jpg)
Laravel Step ZEROThe introduction to Laravel
![Page 2: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/2.jpg)
Agenda
● Lecturer introduce
● PHP in Brief○ PHP Basic (Variable, Controls, Function)
○ PHP Intermediate (OOP)
● Web Application Development World○ CMS (Content Management System)
○ Application Frameworks
● Introduction to Laravel○ What is Laravel?
○ Why Laravel?
○ Prerequisites
● Development Environment
● Workshop & Assignments
![Page 3: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/3.jpg)
● Simply a full stack developers since high school
● Graduated MS from CPE@KMUTT
● Do research but still love application developments
● Dev everything from web to Android to iOS
● Feel free to discuss with me, I love knowledge sharing!
Hello! it’s me, Spicydog!
![Page 4: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/4.jpg)
A Quick Review for PHP
![Page 5: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/5.jpg)
● Established in 1995
● Zend Technologies and PHP communities
● Most popular version: 5.6
● Most recent version: 7.1 (recommend 7.0)
● PHP is a SCRIPT Language
● Designed for web development (I am good at string things)
● Almost dominate the internet,
supported by most hosting,
has so many CMS and frameworks
PHP is everywhere and now here!
![Page 6: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/6.jpg)
Let’s Rock with PHP Variable
$ for variable
$a = “1” // string(1) "1"
$b = ’1’ // string(1) "1"
$c = 1 // int(1)
$d = 1.0 // float(1)
var_dump() for variable information
var_dump($a+$b); // int(2)
var_dump($a.$b); // string(2) "11"
var_dump($a+$c); // int(2)
var_dump($c.$d); // string(2) "11"
var_dump($c+$d); // float(2)
So becareful!
PHP is dynamic type, it works most of the times but it always.
You must cast types with intval(), floatval(), and friends.. sometimes
![Page 7: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/7.jpg)
'string' and "string" are NOT the same!
$a
$b
$c
$a\n$b\n$c\n1
2
3
1
2
3
![Page 8: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/8.jpg)
Controls in PHP are similar to C and Java
If..Else
if ($a) {}
else {}
For
for($i=0; $i<10; $i++;) {}
While
$i=0; while($i<10) {$i++;}
Do..While
$i=0; do{$i++;} while($i<10);
Switch
switch ($i) {
case 0: break;
default: break;
}
![Page 9: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/9.jpg)
Functions in PHP are also similar to C and Java
function name($param1, $param2) {
return $param1 . $param2;
}
name(‘1’,’2’); // string(2) "12"
![Page 10: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/10.jpg)
Class in PHP <?phpclass Foo{ public static $my_static = 'foo';
public function staticValue() { return self::$my_static; }}
class Bar extends Foo{ public function fooStatic() { return parent::$my_static; }}
print Foo::$my_static . "\n";
$foo = new Foo();print $foo->staticValue() . "\n";print $foo->my_static . "\n"; // Undefined "Property" my_static
print $foo::$my_static . "\n";$classname = 'Foo';print $classname::$my_static . "\n"; // As of PHP 5.3.0
print Bar::$my_static . "\n";$bar = new Bar();print $bar->fooStatic() . "\n";?>
self for static
$this for object
:: call to static
-> call to object
http://php.net/manual/en/language.oop5.static.php
![Page 11: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/11.jpg)
Web Application Development World
![Page 12: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/12.jpg)
In web application development world, we..
Do it easy
Do it quick
Do it simple
Do it readable
Do it secure
Do it extendable
We try to use less money and time to have things done!
![Page 13: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/13.jpg)
So we go for CMS and Frameworks
● CMS (Content management System)○ A web application for content management
○ Install and ready to go!
○ Work on most simple tasks
○ Not very flexible
● Application Framework○ A template for application development
○ Pattern the code
○ Avoid reinvent the wheel
○ Easy and dev on top and flexible for most tasks
○ Require programming skills
![Page 14: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/14.jpg)
Getting Started with Laravel
![Page 15: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/15.jpg)
Laravel, a super productive PHP framework
● Laravel first launched in 2011
● Current version is 5.3
● Developed on top of Symfony
● Aims: fun, productive, clean, extendable
● Relatively bad in performance (but not that bad!)
![Page 16: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/16.jpg)
Why Laravel?
● Easy to learn! (hopefully)
● Full of tools, ready for dev, tons of libraries
● We want our application to finish as fast as possible
● We want to work least
● We want our application easy to develop
● Our application is not user intensive
● Save time, save money, and done more things!
Say all of these in one word..
PRODUCTIVITY
![Page 17: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/17.jpg)
But wait!! You have to know..
PHP Basic
PHP with DBMS
PHP OOP
PHP CLI
MVC
Composer
Artisan CLI
OMG
![Page 18: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/18.jpg)
Don’t Worry!I’m here to help you out :)
![Page 19: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/19.jpg)
PHP CLI
CLI stands for Command Line Interface
Similar to Command Prompt and whatever Shell but this is PHP
Try this on your terminal! php -a
Are you using Windows? Good luck, help yourself! GOOGLE
![Page 20: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/20.jpg)
Model-View-Controller
A primitive flow for software development
Client (Request) => Controller (Logic) => Model (Data Logic) => Controller (Login Again) => View (Display) => Client (Response)
Partitioning codesby its functionality
Easy to maintain
This is a must-knownthing in any software development
http://www.tutorialized.com/tutorial/Fundamentals-of-an-MVC-Framework/81946
![Page 21: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/21.jpg)
Composer
The most popular dependency management tool in PHP
Get any libraries by typing in CLI
For example,
Install Laravel, we simply enter:
composer create-project --prefer-dist laravel/laravel blog
Add library to laravel we do:
composer require "laravelcollective/html":"^5.2.0"
Q: Where did I get these commands?
A: Google it man, they are on the websitehttps://getcomposer.org
![Page 22: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/22.jpg)
Artisan CLI
Artisan is a PHP CLI Tool help you manage Laravel components
Simply go to Laravel root directory and type: php artisan
We are going to talk about this later since we are going to use it a lot!
![Page 23: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/23.jpg)
Development Environment
![Page 24: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/24.jpg)
Make sure you can run..
php from your command lineOtherwise, install PHP (we use PHP 5.6+)
composer from your command lineOtherwise, install Composer
Web Server on your computerRecommend Apache for RookieYou can use XAMPP for Windows or MAMP for Mac or LAMP for Linux
PHP IDEI recommend PhpStorm, use your student status to claim a license
GitWe use Git here, you can use SourceTree if you want GUI client
![Page 25: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/25.jpg)
Coding Style
In Laravel, we followPSR-2 Coding Style
Please follow this style =>
![Page 26: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/26.jpg)
Workshop & Assignments
![Page 27: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/27.jpg)
ROCK n’ LOAD
The most valuable skill is the skill to learn new things, so here is your works have to make it done before next time
- Install development environment I have talked in last section
- Install your first Laravel Application
- Have a look at Directory Structure
- Try whatever you want
Extra!
- Wanna in advance? Go watch to Laracasts
- Free public cloud you can get from AWS Free Tier
Or claim free DigitalOcean credit from Github Student
![Page 28: Laravel Step 0 (Introduction)](https://reader031.vdocument.in/reader031/viewer/2022022413/58a28a321a28ab891a8b7e6f/html5/thumbnails/28.jpg)
Woo hoo!No more slides, let’s rock!