Mastering Yii
eBook - ePub

Mastering Yii

Charles R. Portwood II

Share book
  1. 380 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering Yii

Charles R. Portwood II

Book details
Book preview
Table of contents
Citations

About This Book

Advance your modern web application development skills with Yii Framework 2

About This Book

  • Learn to work with the key aspects of Yii Framework 2
  • Explore how to create RESTful APIs with Yii
  • Incorporate codeception with Yii2 to test your code thoroughly

Who This Book Is For

This book is for Yii Framework developers who want to quickly master Yii2. This book assumes some familiarity with Yii2, PHP 5, and HTML5.

What You Will Learn

  • Explore Yii2's conventions and learn how to properly configure Yii2
  • Create both web and console applications
  • Reduce development time by learning to create classes automatically with Gii, Yii2's automatic code generation tool
  • Use Yii2's database migration tool
  • Manage and access databases with Active Record, DAO, and Query Builder
  • Handle user authentication and authorization within Yii2
  • Create RESTful APIs with Yii Framework 2
  • Test applications automatically with codeception

In Detail

The successor of Yii Framework 1.1, Yii2 is a complete rewrite of Yii Framework, one of the most popular PHP 5 frameworks for making modern web applications. The update embraces the best practices and protocols established with newer versions of PHP, while still maintaining the simple, fast, and extendable behavior found in its predecessor.

This book has been written to enhance your skills and knowledge with Yii Framework 2. Starting with configuration and how to initialize new projects, you'll learn how to configure, manage, and use every aspect of Yii2 from Gii, DAO, Query Builder, Active Record, and migrations, to asset manager. You'll also discover how to automatically test your code using codeception.

With this book by your side, you'll have all the skills you need to quickly create rich modern web and console applications with Yii2.

Style and approach

This book is a step-by-step guide to mastering every aspect of Yii Framework 2. Each chapter outlines a new set of tools along with code that can be used to efficiently create modern web and console applications

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mastering Yii an online PDF/ePUB?
Yes, you can access Mastering Yii by Charles R. Portwood II in PDF and/or ePUB format, as well as other popular books in Informatique & Développement d'applications. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781785882425

Mastering Yii


Table of Contents

Mastering Yii
Credits
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
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. Composer, Configuration, Classes, and Path Aliases
Composer
Configuration
Requirements checker
Entry scripts
Web entry script
Configuration files
Web and console configuration files
Database configuration
Parameter configuration
Environment configuration
Setting up our application environment
Setting the web environment for NGINX
Setting the web environment for Apache
Components and objects
Components
Objects
Path aliases
Summary
2. Console Commands and Applications
Configuration and usage
Entry script
Configuration
Setting the console environment
Running console commands
Built-in console commands
The help command
The asset command
The cache command
The fixture command
The Gii command
The message command
The migration command
Creating console commands
Generating help information
Passing command-line arguments
Exit codes
Formatting
Summary
3. Migrations, DAO, and Query Building
Connecting to databases
Additional configuration options
Writing database migrations
An overview of schema
Writing migrations
Running migrations
Altering a database schema
Database access objects
Querying for data
Quoting table and column names
Executing queries
Parameter binding
Transactions
Query Builder
Query construction methods
The select method
The from method
The where method
The string format
The hash format
The operator format
Ordering results
Limiting and offsetting data
Grouping and having
Joins and unions
Executing queries
Examining queries
Iterating over query results
Data providers and data widgets
Data replication and load balancing
Summary
4. Active Record, Models, and Forms
Configuring Gii
Gii for web applications
Gii for console applications
Active Record
The Active Record pattern
Creating Active Record classes
Creating active record classes with Gii
Using Gii's web interface
Using Gii's console interface
Working with Active Record
Model validation rules
Adding custom validators
Customizing validator error messages
Working with validation errors
Manually executing validation rules
Model attribute labels
Active Record relationships
Using multiple database connections with Active Record
Behaviors in Active Record
Working with Active Record
Querying data
Data access
Saving data
Creating new records
Deleting data
Active Record events
Models
Model attributes
Scenarios
Forms
Generating forms with Gii
Generating forms with Gii's web interface
Generating forms with Gii's console interface
Using forms
ActiveForm and input types
Summary
5. Modules, Widgets, and Helpers
Modules
Module components
The module class structure
Controllers
Views and layouts
Registering modules
Dynamically registering modules
Bootstrapping modules
Accessing modules
Managing modules with Composer
Modules in summary
Widgets
Using widgets
Commonly used built-in widgets
Bootstrap widgets
jQuery UI widgets
Yii-specific widgets
Creating custom widgets
A summary of widgets
Helpers
The URL helper
The HTML helper
The JSON helper
The Markdown helper
Variable dumping
Inflector
FileHelper
Summary
6. Asset Management
Asset bundles
Using asset bundles
Configuration
Asset mapping
Asset types and locations
Asset options
Asset publication
Client cache management with asset bundles
Using preprocessor with asset bundles
The asset command line tool
Third-party asset tools
NodeJS
Bower
Grunt
Summary
7. Authenticating and Authorizing Users
Authentication of users
Implementing the user identity interface
Cookie-based authentication
Working with user identities
Authenticating users with forms
Authorization
Access control filters
Role-based access control
Configuring RBAC
Creating permissions and permission relationships
Custom authorization rules
Checking if a user has access to a role
Flash messages
Hashing and encryption
Hashing and verifying passwords
Data encryption and decryption
Data hashing
Summary
8. Routing, Responses, and Events
Routing
Default and catch all routes
Custom routes and URL rules
Parameterizing routes
URL suffixes
HTTP method-specific URL rules
Custom URL rule classes
Dynamic rule generation
Requests
Retrieving request parameters and data
Request headers and cookies
Retrieving client and URL information
Responses
Setting status codes
Web exceptions
Setting response headers
The response body
Redirection
The file output
Events
Event handlers
Triggering events
Class-level events
Global events
Summary
9. RESTful APIs
ActiveController
Configuring ActiveController display fields
Data serialization within responses
Disabling ActiveController actions
Customizing ActiveController actions
Authentication filters
HTTP basic authentication
Query parameter authentication
OAuth2 authentication
Composite authentication
Custom authentication filters
Action-specific authentication
Checking access
Verb filters
Cross-origin resource headers
Rate Limiting
Error handling
Custom API controllers
Returning data
Response Formatting
Summary
10. Testing with Codeception
Reasons for testing
How to approach testing
Testing manually
Testing a few core components
Test-driven development
Configuring Codeception with...

Table of contents