Yii2 Application Development Cookbook - Third Edition

Discover 100 useful recipes that will bring the best out of the Yii2 framework and be on the bleeding edge of web development today

Yii2 Application Development Cookbook - Third Edition

Andrew Bogdanov, Dmitry Eliseev

2 customer reviews
Discover 100 useful recipes that will bring the best out of the Yii2 framework and be on the bleeding edge of web development today
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781785281761
Paperback584 pages

Book Description

Yii is a free, open source web application development framework written in PHP5 that promotes clean DRY design and encourages rapid development. It works to streamline your application development time and helps to ensure an extremely efficient, extensible, and maintainable end product. Being extremely performance optimized, Yii is a perfect choice for any size project. However, it has been built with sophisticated, enterprise applications in mind. You have full control over the configuration from head-to-toe (presentation-to-persistence) to conform to your enterprise development guidelines. It comes packaged with tools to help test and debug your application, and has clear and comprehensive documentation.

This book is a collection of Yii2 recipes. Each recipe is represented as a full and independent item, which showcases solutions from real web-applications. So you can easily reproduce them in your environment and learn Yii2 fast and without tears. All recipes are explained with step-by-step code examples and clear screenshots.

Yii2 is like a suit that looks great off the rack, but is also very easy to tailor to fit your needs. Virtually every component of the framework is extensible. This book will show how to use official extensions, extend any component, or write a new one.

This book will help you create modern web applications quickly, and make sure they perform well using examples and business logic from real life. You will deal with the Yii command line, migrations, and assets. You will learn about role-based access, security, and deployment. We’ll show you how to easily get started, configure your environment, and be ready to write web applications efficiently and quickly.

Table of Contents

Chapter 1: Fundamentals
Introduction
Installing the framework
Application templates
Dependency injection container
Service locator
Code generation
Configuring components
Working with events
Using external code
Chapter 2: Routing, Controllers, and Views
Introduction
Configuring URL rules
Generating URLs
Using regular expressions in URL rules
Using a base controller
Using standalone actions
Creating a custom filter
Displaying static pages
Using flash messages
Using the controller context in a view
Reusing views with partials
Using blocks
Using decorators
Defining multiple layouts
Pagination and sorting data
Chapter 3: ActiveRecord, Model, and Database
Introduction
Getting data from a database
Defining and using multiple DB connections
Customizing the ActiveQuery class
Processing model fields with AR event-like methods
Automating timestamps
Setting up an author automatically
Setting up a slug automatically
Transactions
Replication and read-write splitting
Implementing single table inheritance
Chapter 4: Forms
Introduction
Writing your own validators
Uploading files
Adding and customizing CaptchaWidget
Customizing Captcha
Creating a custom input widget
Tabular input
Conditional validation
Complex forms with multiple models
AJAX-dependent drop-down list
AJAX validation
Creating a custom client-side validation
Chapter 5: Security
Introduction
Authentication
Using controller filters
Preventing XSS
Preventing SQL injections
Preventing CSRF
Using RBAC
Encrypting/Decrypting data
Chapter 6: RESTful Web Services
Introduction
Creating a REST server
Authentication
Rate limiting
Versioning
Error handling
Chapter 7: Official Extensions
Introduction
Authentication client
SwiftMailer e-mail library
Faker fixture data generator
Imagine library
MongoDB driver
ElasticSearch engine adapter
Gii code generator
Pjax jQuery plugin
Redis database driver
Chapter 8: Extending Yii
Introduction
Creating helpers
Creating model behaviors
Creating components
Creating reusable controller actions
Creating reusable controllers
Creating a widget
Creating CLI commands
Creating filters
Creating modules
Creating a custom view renderer
Creating a multilanguage application
Making extensions distribution-ready
Chapter 9: Performance Tuning
Following best practices
Speeding up session handling
Using cache dependencies and chains
Profiling an application with Yii
Leveraging HTTP caching
Combining and minimizing assets
Running Yii2 on HHVM
Chapter 10: Deployment
Introduction
Changing the Yii directory layout
Moving an application webroot
Changing an advanced application template
Moving configuration parts into separate files
Using multiple configurations to simplify the deployment
Implementing and executing cron jobs
Maintenance mode
Deployment tools
Chapter 11: Testing
Introduction
Testing application with Codeception
Unit testing with PHPUnit
Unit testing with Atoum
Unit testing with Behat
Chapter 12: Debugging, Logging, and Error Handling
Introduction
Using different log routes
Analyzing the Yii error stack trace
Logging and using the context information
Displaying custom errors
Custom panel for debug extension

What You Will Learn

  • See the new version of the Yii2 framework and application development practices
  • Write your applications more efficiently using shortcuts, Yii’s core functionality, and the best practices in Web 2.0
  • Get data from a database, and deal with Active Record, migrations, widgets, and core features
  • Easily update your skills from the previous version of the framework
  • Explore how to use Yii with different JavaScript frameworks and libraries such as WebSockets, Angular, Ember, Backbone and React
  • Learn how to keep your application secure according to the general web application security principle "filter input, escape output.
  • Write RESTfull Web Services using Yii2 and built-in features
  • Correctly install and use official extensions in your projects
  • Effectively create and implement your own Yii extension, and also ensure your extension is reusable and useful for the community

Authors

Table of Contents

Chapter 1: Fundamentals
Introduction
Installing the framework
Application templates
Dependency injection container
Service locator
Code generation
Configuring components
Working with events
Using external code
Chapter 2: Routing, Controllers, and Views
Introduction
Configuring URL rules
Generating URLs
Using regular expressions in URL rules
Using a base controller
Using standalone actions
Creating a custom filter
Displaying static pages
Using flash messages
Using the controller context in a view
Reusing views with partials
Using blocks
Using decorators
Defining multiple layouts
Pagination and sorting data
Chapter 3: ActiveRecord, Model, and Database
Introduction
Getting data from a database
Defining and using multiple DB connections
Customizing the ActiveQuery class
Processing model fields with AR event-like methods
Automating timestamps
Setting up an author automatically
Setting up a slug automatically
Transactions
Replication and read-write splitting
Implementing single table inheritance
Chapter 4: Forms
Introduction
Writing your own validators
Uploading files
Adding and customizing CaptchaWidget
Customizing Captcha
Creating a custom input widget
Tabular input
Conditional validation
Complex forms with multiple models
AJAX-dependent drop-down list
AJAX validation
Creating a custom client-side validation
Chapter 5: Security
Introduction
Authentication
Using controller filters
Preventing XSS
Preventing SQL injections
Preventing CSRF
Using RBAC
Encrypting/Decrypting data
Chapter 6: RESTful Web Services
Introduction
Creating a REST server
Authentication
Rate limiting
Versioning
Error handling
Chapter 7: Official Extensions
Introduction
Authentication client
SwiftMailer e-mail library
Faker fixture data generator
Imagine library
MongoDB driver
ElasticSearch engine adapter
Gii code generator
Pjax jQuery plugin
Redis database driver
Chapter 8: Extending Yii
Introduction
Creating helpers
Creating model behaviors
Creating components
Creating reusable controller actions
Creating reusable controllers
Creating a widget
Creating CLI commands
Creating filters
Creating modules
Creating a custom view renderer
Creating a multilanguage application
Making extensions distribution-ready
Chapter 9: Performance Tuning
Following best practices
Speeding up session handling
Using cache dependencies and chains
Profiling an application with Yii
Leveraging HTTP caching
Combining and minimizing assets
Running Yii2 on HHVM
Chapter 10: Deployment
Introduction
Changing the Yii directory layout
Moving an application webroot
Changing an advanced application template
Moving configuration parts into separate files
Using multiple configurations to simplify the deployment
Implementing and executing cron jobs
Maintenance mode
Deployment tools
Chapter 11: Testing
Introduction
Testing application with Codeception
Unit testing with PHPUnit
Unit testing with Atoum
Unit testing with Behat
Chapter 12: Debugging, Logging, and Error Handling
Introduction
Using different log routes
Analyzing the Yii error stack trace
Logging and using the context information
Displaying custom errors
Custom panel for debug extension

Book Details

ISBN 139781785281761
Paperback584 pages
Read More
From 2 reviews

Read More Reviews

Recommended for You

Web Application Development with Yii 2 and PHP Book Cover
Web Application Development with Yii 2 and PHP
$ 21.99
$ 15.40
Yii2 By Example Book Cover
Yii2 By Example
$ 35.99
$ 25.20
Mastering Yii Book Cover
Mastering Yii
$ 39.99
$ 8.00
ODP.NET Developer's Guide: Oracle Database 10g Development with Visual Studio 2005 and the Oracle Data Provider for .NET Book Cover
ODP.NET Developer's Guide: Oracle Database 10g Development with Visual Studio 2005 and the Oracle Data Provider for .NET
$ 29.99
$ 21.00
Using Cycles Render Engine in Blender 3D [Video] Book Cover
Using Cycles Render Engine in Blender 3D [Video]
$ 124.99
$ 106.25
Docker - A Better Way to Build Apps [Video] Book Cover
Docker - A Better Way to Build Apps [Video]
$ 124.99
$ 106.25