Modern PHP. New Features and Good Practices - Helion
ISBN: 978-14-919-0499-2
stron: 270, Format: ebook
Data wydania: 2015-02-16
Księgarnia: Helion
Cena książki: 101,15 zł (poprzednio: 117,62 zł)
Oszczędzasz: 14% (-16,47 zł)
PHP is experiencing a renaissance, though it may be difficult to tell with all of the outdated PHP tutorials online. With this practical guide, you’ll learn how PHP has become a full-featured, mature language with object-orientation, namespaces, and a growing collection of reusable component libraries.
Author Josh Lockhart—creator of PHP The Right Way, a popular initiative to encourage PHP best practices—reveals these new language features in action. You’ll learn best practices for application architecture and planning, databases, security, testing, debugging, and deployment. If you have a basic understanding of PHP and want to bolster your skills, this is your book.
- Learn modern PHP features, such as namespaces, traits, generators, and closures
- Discover how to find, use, and create PHP components
- Follow best practices for application security, working with databases, errors and exceptions, and more
- Learn tools and techniques for deploying, tuning, testing, and profiling your PHP applications
- Explore Facebook’s HVVM and Hack language implementations—and how they affect modern PHP
- Build a local development environment that closely matches your production server
Osoby które kupowały "Modern PHP. New Features and Good Practices", wybierały także:
- PHP 8 Programming Tips, Tricks and Best Practices 157,37 zł, (29,90 zł -81%)
- Domain-Driven Design in PHP 135,91 zł, (29,90 zł -78%)
- PHP Microservices 135,91 zł, (29,90 zł -78%)
- Drupal 8 Module Development. Second edition 124,58 zł, (29,90 zł -76%)
- Mastering The Faster Web with PHP, MySQL, and JavaScript 124,58 zł, (29,90 zł -76%)
Spis treści
Modern PHP. New Features and Good Practices eBook -- spis treści
- Preface
- What You Need to Know About This Book
- How This Book Is Organized
- Conventions Used in This Book
- Using Code Examples
- Safari Books Online
- How to Contact Us
- Acknowledgments
- I. Language Features
- 1. The New PHP
- Past
- Present
- Future
- 2. Features
- Namespaces
- Why We Use Namespaces
- Declaration
- Import and Alias
- Helpful Tips
- Multiple imports
- Multiple namespaces in one file
- Global namespace
- Autoloading
- Code to an Interface
- Traits
- Why We Use Traits
- How to Create a Trait
- How to Use a Trait
- Generators
- Create a Generator
- Use a Generator
- Closures
- Create
- Attach State
- Zend OPcache
- Enable Zend OPcache
- Configure Zend OPcache
- Use Zend OPcache
- Built-in HTTP server
- Start the Server
- Configure the Server
- Router Scripts
- Detect the Built-in Server
- Drawbacks
- Whats Next
- Namespaces
- II. Good Practices
- 3. Standards
- PHP-FIG to the Rescue
- Framework Interoperability
- Interfaces
- Autoloading
- Style
- What Is a PSR?
- PSR-1: Basic Code Style
- PSR-2: Strict Code Style
- PSR-3: Logger Interface
- Write a PSR-3 Logger
- Use a PSR-3 Logger
- PSR-4: Autoloaders
- Why Autoloaders Are Important
- The PSR-4 Autoloader Strategy
- How to Write a PSR-4 Autoloader (and Why You Shouldnt)
- 4. Components
- Why Use Components?
- What Are Components?
- Components Versus Frameworks
- Not All Frameworks Are Bad
- Use the Right Tool for the Job
- Find Components
- Shop
- Choose
- Leave Feedback
- Use PHP Components
- How to Install Composer
- How to Use Composer
- Component names
- Component installation
- Example Project
- The composer.lock file
- Autoloading PHP components
- Implement scan.php
- Composer and Private Repositories
- Create PHP Components
- Vendor and Package Names
- Namespaces
- Filesystem Organization
- The composer.json File
- The README file
- Component Implementation
- Version Control
- Packagist Submission
- Using the Component
- 5. Good Practices
- Sanitize, Validate, and Escape
- Sanitize Input
- HTML
- SQL queries
- User profile information
- Validate Data
- Escape Output
- Sanitize Input
- Passwords
- Never Know User Passwords
- Never Restrict User Passwords
- Never Email User Passwords
- Hash User Passwords with bcrypt
- Password Hashing API
- User registration
- User login
- Verify password
- Rehash password
- Password Hashing API for PHP < 5.5.0
- Dates, Times, and Time Zones
- Set a Default Time Zone
- The DateTime Class
- The DateInterval Class
- The DateTimeZone Class
- The DatePeriod Class
- The nesbot/carbon Component
- Databases
- The PDO Extension
- Database Connections and DSNs
- Remove your database credentials from your PHP code
- Prepared Statements
- Query Results
- Transactions
- Multibyte Strings
- Character Encoding
- Output UTF-8 Data
- Streams
- Stream Wrappers
- The file:// stream wrapper
- The php:// stream wrapper
- Other stream wrappers
- Custom stream wrappers
- Stream Context
- Stream Filters
- Custom Stream Filters
- Stream Wrappers
- Errors and Exceptions
- Exceptions
- Throw exceptions
- Catch exceptions
- Exception Handlers
- Errors
- Error Handlers
- Errors and Exceptions During Development
- Production
- Exceptions
- Sanitize, Validate, and Escape
- III. Deployment, Testing, and Tuning
- 6. Hosting
- Shared Server
- Virtual Private Server
- Dedicated Server
- PaaS
- Choose a Hosting Plan
- 7. Provisioning
- Our Goal
- Server Setup
- First Login
- Software Updates
- Nonroot User
- Ubuntu
- CentOS
- SSH Key-Pair Authentication
- Disable Passwords and Root Login
- PHP-FPM
- Install
- Global Configuration
- Pool Configuration
- Nginx
- Install
- Ubuntu
- CentOS
- Virtual Host
- Install
- Automate Server Provisioning
- Delegate Server Provisioning
- Further Reading
- Whats Next
- 8. Tuning
- The php.ini File
- Memory
- Zend OPcache
- File Uploads
- Max Execution Time
- Session Handling
- Output Buffering
- Realpath Cache
- Up Next
- 9. Deployment
- Version Control
- Automate Deployment
- Make It Simple
- Make It Predictable
- Make It Reversible
- Capistrano
- How It Works
- Install
- Configure
- The config/deploy.rb file
- The config/deploy/production.rb file
- Authenticate
- Prepare the Remote Server
- Virtual host
- Software dependencies
- Capistrano Hooks
- Deploy Your Application
- Roll Back Your Application
- Further Reading
- Whats Next
- 10. Testing
- Why Do We Test?
- When Do We Test?
- Before
- During
- After
- What Do We Test?
- How Do We Test?
- Unit Tests
- Test-Driven Development (TDD)
- Behavior-Driven Development (BDD)
- PHPUnit
- Directory Structure
- Install PHPUnit
- Install Xdebug
- Configure PHPUnit
- The Whovian Class
- The WhovianTest Test Case
- Test 1: __construct()
- Test 2: say()
- Test 3: respondTo() in agreement
- Test 4: respondTo() in disagreement
- Run Tests
- Code Coverage
- Continuous Testing with Travis CI
- Setup
- Run
- Further Reading
- Whats Next
- 11. Profiling
- When to Use a Profiler
- Types of Profilers
- Xdebug
- Configure
- Trigger
- Analyze
- XHProf
- Install
- XHGUI
- Configure
- Trigger
- New Relic Profiler
- Blackfire Profiler
- Further Reading
- Whats Next
- 12. HHVM and Hack
- HHVM
- PHP at Facebook
- HHVM and Zend Engine Parity
- Is HHVM Right for Me?
- Install
- Configure
- Extensions
- Monitor HHVM with Supervisord
- HHVM, FastCGI, and Nginx
- The Hack Language
- Convert PHP to Hack
- What is a Type?
- Static Typing
- Dynamic Typing
- Hack Goes Both Ways
- Hack Type Checking
- Hack Modes
- Hack Syntax
- Property annotations
- Argument annotations
- Return-type annotations
- Hack Data Structures
- HHVM/Hack vs. PHP
- Further Reading
- HHVM
- 13. Community
- Local PUG
- Conferences
- Mentoring
- Stay Up-to-Date
- Websites
- Mailing Lists
- Podcasts
- Humor
- A. Installing PHP
- Linux
- Package Managers
- Ubuntu 14.04 LTS
- 1. Add software dependencies
- 2. Add ppa:ondrej/php PPA
- 3. Install PHP
- CentOS 7
- 1. Add the EPEL repository
- 2. Install PHP
- OS X
- MAMP
- Install
- Extend
- Limitations
- Homebrew
- XCode command-line tools
- Install
- Directory permissions
- Environment PATH
- Tap formulae repositories
- Install PHP
- Install PHP extensions
- MAMP
- Build from Source
- Get the Source Code
- The src/ directory
- Download the source code
- Configure PHP
- The ./configure command
- Make and install PHP
- Create the php.ini file
- Get the Source Code
- Windows
- WAMP
- Zend Server
- Linux
- B. Local Development Environments
- VirtualBox
- Vagrant
- Commands
- Boxes
- Initialize
- Provision
- Puppet
- Chef
- Synced folders
- Get started
- Laravel Homestead
- PuPHPet
- Vaprobash
- Index