万本电子书0元读

万本电子书0元读

顶部广告

Learning PHP 7电子书

售       价:¥

40人正在读 | 0人评论 6.2

作       者:Antonio Lopez

出  版  社:Packt Publishing

出版时间:2016-03-29

字       数:288.2万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn the art of PHP programming through this example-rich book filled to the brim with tutorials every PHP developer needs to know About This Book Set up the PHP environment and get started with web programming Leverage the potential of PHP for server-side programming, memory management, and object-oriented programming (OOP) This book is packed with real-life examples to help you implement the concepts as you learn Who This Book Is For If you are a web developer or programmer who wants to create real-life web applications using PHP 7, or a beginner who wants to get started with PHP 7 programming, this book is for you. Prior knowledge of PHP, PHP 7, or programming is not mandatory. What You Will Learn Set up a server on your machine with PHP Use PHP syntax with the built-in server to create apps Apply the OOP paradigm to PHP to write richer code Use MySQL to manage data in your web applications Create a web application from scratch using MVC Add tests to your web application and write testable code Use an existing PHP framework to build and manage your applications Build REST APIs for your PHP applications Test the behavior of web applications with Behat In Detail PHP is a great language for building web applications. It is essentially a server-side *ing language that is also used for general purpose programming. PHP 7 is the latest version with a host of new features, and it provides major backwards-compatibility breaks. This book begins with the fundamentals of PHP programming by covering the basic concepts such as variables, functions, class, and objects. You will set up PHP server on your machine and learn to read and write procedural PHP code. After getting an understanding of OOP as a paradigm, you will execute MySQL queries on your database. Moving on, you will find out how to use MVC to create applications from scratch and add tests. Then, you will build REST APIs and perform behavioral tests on your applications. By the end of the book, you will have the skills required to read and write files, debug, test, and work with MySQL. Style and approach This book begins with the basics that all PHP developers use every day and then dives deep into detailed concepts and tricks to help you speed through development. You will be able to learn the concepts by performing practical tasks and implementing them in your daily activities, all at your own pace.
目录展开

Learning PHP 7

Table of Contents

Learning PHP 7

Credits

About the Author

About the Reviewer

www.PacktPub.com

eBooks, discount offers, and more

Why subscribe?

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. Setting Up the Environment

Setting up the environment with Vagrant

Introducing Vagrant

Installing Vagrant

Using Vagrant

Setting up the environment on OS X

Installing PHP

Installing MySQL

Installing Nginx

Installing Composer

Setting up the environment on Windows

Installing PHP

Installing MySQL

Installing Nginx

Installing Composer

Setting up the environment on Ubuntu

Installing PHP

Installing MySQL

Installing Nginx

Summary

2. Web Applications with PHP

The HTTP protocol

A simple example

Parts of the message

URL

The HTTP method

Body

Headers

The status code

A more complex example

Web applications

HTML, CSS, and JavaScript

Web servers

How they work

The PHP built-in server

Putting things together

Summary

3. Understanding PHP Basics

PHP files

Variables

Data types

Operators

Arithmetic operators

Assignment operators

Comparison operators

Logical operators

Incrementing and decrementing operators

Operator precedence

Working with strings

Arrays

Initializing arrays

Populating arrays

Accessing arrays

The empty and isset functions

Searching for elements in an array

Ordering arrays

Other array functions

PHP in web applications

Getting information from the user

HTML forms

Persisting data with cookies

Other superglobals

Control structures

Conditionals

Switch…case

Loops

While

Do…while

For

Foreach

Functions

Function declaration

Function arguments

The return statement

Type hinting and return types

The filesystem

Reading files

Writing files

Other filesystem functions

Summary

4. Creating Clean Code with OOP

Classes and objects

Class properties

Class methods

Class constructors

Magic methods

Properties and methods visibility

Encapsulation

Static properties and methods

Namespaces

Autoloading classes

Using the __autoload function

Using the spl_autoload_register function

Inheritance

Introducing inheritance

Overriding methods

Abstract classes

Interfaces

Polymorphism

Traits

Handling exceptions

The try…catch block

The finally block

Catching different types of exceptions

Design patterns

Factory

Singleton

Anonymous functions

Summary

5. Using Databases

Introducing databases

MySQL

Schemas and tables

Understanding schemas

Database data types

Numeric data types

String data types

List of values

Date and time data types

Managing tables

Keys and constraints

Primary keys

Foreign keys

Unique keys

Indexes

Inserting data

Querying data

Using PDO

Connecting to the database

Performing queries

Prepared statements

Joining tables

Grouping queries

Updating and deleting data

Updating data

Foreign key behaviors

Deleting data

Working with transactions

Summary

6. Adapting to MVC

The MVC pattern

Using Composer

Managing dependencies

Autoloader with PSR-4

Adding metadata

The index.php file

Working with requests

The request object

Filtering parameters from requests

Mapping routes to controllers

The router

URLs matching with regular expressions

Extracting the arguments of the URL

Executing the controller

M for model

The customer model

The book model

The sales model

V for view

Introduction to Twig

The book view

Layouts and blocks

Paginated book list

The sales view

The error template

The login template

C for controller

The error controller

The login controller

The book controller

Borrowing books

The sales controller

Dependency injection

Why is dependency injection necessary?

Implementing our own dependency injector

Summary

7. Testing Web Applications

The necessity for tests

Types of tests

Unit tests and code coverage

Integrating PHPUnit

The phpunit.xml file

Your first test

Running tests

Writing unit tests

The start and end of a test

Assertions

Expecting exceptions

Data providers

Testing with doubles

Injecting models with DI

Customizing TestCase

Using mocks

Database testing

Test-driven development

Theory versus practice

Summary

8. Using Existing PHP Frameworks

Reviewing frameworks

The purpose of frameworks

The main parts of a framework

Other features of frameworks

Authentication and roles

ORM

Cache

Internationalization

Types of frameworks

Complete and robust frameworks

Lightweight and flexible frameworks

An overview of famous frameworks

Symfony 2

Zend Framework 2

Other frameworks

The Laravel framework

Installation

Project setup

Adding the first endpoint

Managing users

User registration

User login

Protected routes

Setting up relationships in models

Creating complex controllers

Adding tests

The Silex microframework

Installation

Project setup

Managing configuration

Setting the template engine

Adding a logger

Adding the first endpoint

Accessing the database

Silex versus Laravel

Summary

9. Building REST APIs

Introducing APIs

Introducing REST APIs

The foundations of REST APIs

HTTP request methods

GET

POST and PUT

DELETE

Status codes in responses

2xx – success

3xx – redirection

4xx – client error

5xx – server error

REST API security

Basic access authentication

OAuth 2.0

Using third-party APIs

Getting the application's credentials

Setting up the application

Requesting an access token

Fetching tweets

The toolkit of the REST API developer

Testing APIs with browsers

Testing APIs using the command line

Best practices with REST APIs

Consistency in your endpoints

Document as much as you can

Filters and pagination

API versioning

Using HTTP cache

Creating a REST API with Laravel

Setting OAuth2 authentication

Installing OAuth2Server

Setting up the database

Enabling client-credentials authentication

Requesting an access token

Preparing the database

Setting up the models

Designing endpoints

Adding the controllers

Testing your REST APIs

Summary

10. Behavioral Testing

Behavior-driven development

Introducing continuous integration

Unit tests versus acceptance tests

TDD versus BDD

Business writing tests

BDD with Behat

Introducing the Gherkin language

Defining scenarios

Writing Given-When-Then test cases

Reusing parts of scenarios

Writing step definitions

The parameterization of steps

Running feature tests

Testing with a browser using Mink

Types of web drivers

Installing Mink with Goutte

Interaction with the browser

Summary

Index

累计评论(0条) 1个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部