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

Cookbook
Andrew Bogdanov, Dmitry Eliseev, Alexander Makarov

1 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
$39.99
$49.99
RRP $39.99
RRP $49.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2017

With unlimited access to a constantly growing library of over 4,000 eBooks and Videos, a subscription to Mapt gives you everything you need to learn new skills. Cancel anytime.

Free Sample

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 1 reviews

Read More Reviews

Recommended for You