• Complain

Kelt Dockins - Design Patterns in PHP and Laravel

Here you can read online Kelt Dockins - Design Patterns in PHP and Laravel full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2016, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Kelt Dockins Design Patterns in PHP and Laravel
  • Book:
    Design Patterns in PHP and Laravel
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2016
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Design Patterns in PHP and Laravel: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Design Patterns in PHP and Laravel" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Learn each of the original gang of four design patterns, and how they are relevant to modern PHP and Laravel development. Written by a working developer who uses these patterns every day, you will easily be able to implement each pattern into your workflow and improve your development. Each pattern is covered with full examples of how it can be used. Too often design patterns are explained using tricky concepts, when in fact they are easy to use and can enrich your everyday development. Design Patterns in PHP and Laravel aims to break down tricky concepts into humorous and easy-to-recall details, so that you can begin using design patterns easily in your everyday work with PHP and Laravel. This book teaches you design patterns in PHP and Laravel using real-world examples and plenty of humor. What You Will Learn Use the original gang of four design patterns in your PHP and Laravel development How each pattern should be used Solve problems when using the patterns Remember each pattern using mnemonics Who This Book Is For People using Laravel and PHP to do their job and want to improve their understanding of design patterns.

Kelt Dockins: author's other books


Who wrote Design Patterns in PHP and Laravel? Find out the surname, the name of the author of the book and a list of all author's works by series.

Design Patterns in PHP and Laravel — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Design Patterns in PHP and Laravel" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Kelt Dockins 2017
Kelt Dockins Design Patterns in PHP and Laravel 10.1007/978-1-4842-2451-9_1
1. Laravel Basics
Kelt Dockins 1
(1)
Dolph, Arkansas, USA
If youre going to be doing PHP development, you should download Laravel. Symfony and Laravel are the most popular and best frameworks for PHP in the world. To get Laravel on your machine you can follow the . You will need PHP7 with the OpenSSL, PDO, Mbstring, Tokenizer, and XML PHP. It also requires PHP version 5.6.4 or above enabled. You know how to install those, right? Awesome. But just in case, on Ubuntu, use the following code.
Install PHP and a Few Dependencies
> sudo add-apt-repository ppa:ondrej/php
> sudo apt-get update
> sudo apt-get install php7.0 php7.0-curl php7.0-mcrypt
Now, to create a new laravel app we simply follow the instructions provided to us on https://laravel.com/docs/5.3/installation#installing-laravel inside the folder named designpatterns . As you build out various applications in the book, consult the git branch for each chapter so you git Jedis can trace along.
The next thing you will do is look at Composer. Laravel is built off of about 20 Composer packages; Composer is the cats meow (see Figure for important information).
Figure 1-1 Meow What Is Composer Composer is the dependency management - photo 1
Figure 1-1.
Meow
What Is Composer?
Composer is the dependency management tool for PHP. It allows you to list the packages your application depends upon to function correctly. A file in the root of the project named composer.json allows for plenty of configuration options, so lets brush over some of those.
Composer does several neat things:
  • Dependency management with packages
  • PSR and custom file-based autoloading
  • Compiler optimization to help code run faster
  • Custom hooks into lifecycle events, such as application installed, updated, or first created.
  • Stability checking
With your favorite text editor, open up the composer.json file inside the project root. Note that throughout this book file names will all be relative to the project root. Just to be clear here, when I say project root , that means directly inside the designpatterns folder you created, so app/MODELS/User.php is actually the path /home/kelt/book/designpatterns/app/models/User.php on my machine.
Meta Information
In the first part of the Composer manifest, you see basic meta information .
composer.json
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
All of this information is used by a web site called , which catalogs packages out there in the wild. As a standard practice, if you create packages to host on Packagist youll probably want the name the same as the GitHub repository for that package.
Dependency Management
Next you see a require block. Here is where package dependency management comes into play. Currently you are only requiring the Laravel framework, which is made up of many other packages; however, as time goes on you will add additional packages.
composer.json
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*"
},
Seems pretty straightforward, right? One gotcha here though is that you might see a 4.1 or >=1.0,<1.1 | >=1.2. Visiting .
Table 1-1.
Version Rules
Name
Example
Description
Exact version
1.0.2
You can specify the exact version of a package.
Range
>=1.0
By using comparison operators you can specify ranges of valid versions.
>=1.0,<2.0
Valid operators are >, >=, <, <=, !=.
>=1.0,<1.1 | >=1.2
You can define multiple ranges, separated by a comma, which will be treated as a logical AND. A pipe symbol | will be treated as a logical OR. AND has higher precedence than OR.
Wildcard
1.0.*
You can specify a pattern with a * wildcard. 1.0.* is the equivalent of >=1.0,<1.1.
Tilde Operator
1.2
Very useful for projects that follow semantic versioning. 1.2 is equivalent to >=1.2,<2.0.
Although it isnt shown here, you could add a mapping for development only packages by using require-dev. Some good candidates for development only packages are behat , phpspec , and clockwork .
Autoloading
Earlier I mentioned that Composer comes with an autoloader and even optimizes the PHP to run faster. It knows how to do this because of the autoload section.
composer.json
"autoload": {
"classmap": [
"database"
],
"psr-4":{
"App\\": "app/"
}
},
You can also use PSR autoloading. If youve never heard of PSR, take a moment and go to http://petermoulding.com/php/psr . Basically it deals with standardizing the folder structure, namespace, and class names of PHP.
Laravel 5 uses psr-4 autoloading unlike it's predecessor Laravel 4. If you look inside of composer.json you will notice these lines
"psr-4": {
"App" : "app/"
}
This allows us to reference a file such as app/Services/FooService.php with the fully qualified namespace `use App\Services\FooService;` inside another php file.
Now your application will look inside the app folder and autoload any files from that directory for you. Pretty nifty, right?
Lifecycle Hooks/Scripts
Below are a list of scripts you execute after running composer install or composer update or composer create-project (respectively).
composer.json
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimze"
],
"post-update-cmd": [
"illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
],
},
You can tap into certain events of composer if you want to run custom commands here. I use these hooks to automatically run things like migrations any time composer install is executed on the server. When you deploy to production servers, you just follow this simple two-step process:
  1. git pull
  2. composer install
You dont have to remember to run migrations or clean assets or whatever else because you do that after composer install finishes running.
What is the difference between composer install and composer update?
Running composer update will do two things.
  1. It will update all required packages to the latest version matched.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Design Patterns in PHP and Laravel»

Look at similar books to Design Patterns in PHP and Laravel. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Design Patterns in PHP and Laravel»

Discussion, reviews of the book Design Patterns in PHP and Laravel and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.