Yii2 By Example

Develop complete web applications from scratch through practical examples and tips for beginners and more advanced users

Yii2 By Example

Fabrizio Caldarelli

1 customer reviews
Develop complete web applications from scratch through practical examples and tips for beginners and more advanced users
Mapt Subscription
FREE
$29.99/m after trial
eBook
$25.20
RRP $35.99
Print + eBook
$44.99
RRP $44.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
$25.20
$44.99
$29.99p/m after trial
RRP $35.99
RRP $44.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 139781785287411
Paperback344 pages

Book Description

Yii is a high-performance PHP framework best for developing Web 2.0 applications. It provides fast, secure, and professional features to create robust projects, however, this rapid development requires the ability to organize common tasks together to build a complete application. It's all too easy to get confused; this is where this book comes in.

This book contains a series of practical project examples for developers starting from scratch. Each section contains the most relevant theories for every topic as you walk through developing each project, focusing on key aspects that commonly confuse users.

The book starts with all the framework’s basic concepts, such as controllers and views, to introduce you to Yii and creating your first application, a simple news reader. You will be learn to configure URL rules to make a pretty URL, essential for search engine optimization. Next, you will walk through Model and ActiveRecord, key concepts in database interaction.

The second application you will develop is a reservation system that allows you to manage rooms, customers, and reservations. For this, you will use database connection through SQL and ActiveRecord. More complex than the first one, this application will introduce you to the advanced template of Yii 2, splitting the app into two parts: a frontend for all visitors and a backend for the admin. Finally, you will move on to the last two applications: one that allows connections from remote clients, through RESTful components of Yii 2, and another that creates and organizes automatic tasks using the console application structure of Yii 2.

Table of Contents

Chapter 1: Starting with Yii2
Requirements and tools
Installing Yii2 with Composer
Application structure
Application properties
Naming convention
Summary
Chapter 2: Creating a Simple News Reader
Creating Controller and Action
Creating a view to display a news list
How the controller sends data to view
Splitting the common view content into reusable views
Creating static pages
Sharing data between views and layout
Layout with dynamic block
Using multiple layouts
Summary
Chapter 3: Making Pretty URLs
Using pretty URLs
Custom URL rules
Default parameters in rules
The complete URL rule parameters
The URL pattern to support the multilanguage view
Creating the rule class
Summary
Chapter 4: Creating a Room through Forms
Creating a Model
Using ActiveForm
Format date, time, and numbers
Uploading files
Summary
Chapter 5: Developing a Reservation System
Configuring a DB connection
Using Gii to create room, customer, and reservation models
Using ActiveRecord to manipulate data
Working with relationships
How to save a model from a form
Setting up the GMT time zone
Using multiple database connections
Summary
Chapter 6: Using a Grid for Data and Relations
Introduction
DataProvider for grids
Using a grid
Custom columns in a grid
Filters in GridView
Displaying and filtering ActiveRecord relational data in a grid's column
A summarized footer row in a grid
Multiple grids on one page
Summary
Chapter 7: Working on the User Interface
Using Gii to generate CRUD
Customize JavaScript and CSS
Using AJAX
Using the Bootstrap widget
Multiple models in the same view
Saving linked models in the same view
Summary
Chapter 8: Log in to the App
Creating a user login
Configuring user authorization
Mixing ACF and RBAC
Summary
Chapter 9: Frontend to Display Rooms to Everyone
Using an advanced template to split frontend and backend
Configuring an application using init
Sharing ActiveRecord models among applications
Customizing a URL in the advanced template
How to use the advanced template in the shared hosting
Summary
Chapter 10: Localize the App
Setting the default language
File-based translations
Placeholders formatting
DB-based translations
Summary
Chapter 11: Creating an API for Use in a Mobile App
Configuring a REST app in the advanced template
Creating a controller
Authentication
New controller action
Customizing authentication and response
Other forms of export – RSS
Summary
Chapter 12: Create a Console Application to Automate the Periodic Task
Interacting with console applications
Creating a console controller
Formatting the output from the console
Implementing and executing cron jobs
Summary
Chapter 13: Final Refactoring
Creating widgets
Creating components
Creating modules
Generating an API documentation
Summary

What You Will Learn

  • Understand basic concepts, along with the installation and customization of Yii
  • Discover models, controllers, and views—concepts applied in a web context—and how they are employed in Yii
  • Use ActiveRecord to manipulate a database
  • Add access control to your web application through authentication and authorization
  • Install and customize an advanced template for multiple applications in the same project
  • Create a RESTful Web Service to allow remote access to data
  • Develop a console application to launch a command in the console as an automated task (cron job)
  • Make code reusable through widgets and components and localize text messages to make a multilanguage web app

Authors

Table of Contents

Chapter 1: Starting with Yii2
Requirements and tools
Installing Yii2 with Composer
Application structure
Application properties
Naming convention
Summary
Chapter 2: Creating a Simple News Reader
Creating Controller and Action
Creating a view to display a news list
How the controller sends data to view
Splitting the common view content into reusable views
Creating static pages
Sharing data between views and layout
Layout with dynamic block
Using multiple layouts
Summary
Chapter 3: Making Pretty URLs
Using pretty URLs
Custom URL rules
Default parameters in rules
The complete URL rule parameters
The URL pattern to support the multilanguage view
Creating the rule class
Summary
Chapter 4: Creating a Room through Forms
Creating a Model
Using ActiveForm
Format date, time, and numbers
Uploading files
Summary
Chapter 5: Developing a Reservation System
Configuring a DB connection
Using Gii to create room, customer, and reservation models
Using ActiveRecord to manipulate data
Working with relationships
How to save a model from a form
Setting up the GMT time zone
Using multiple database connections
Summary
Chapter 6: Using a Grid for Data and Relations
Introduction
DataProvider for grids
Using a grid
Custom columns in a grid
Filters in GridView
Displaying and filtering ActiveRecord relational data in a grid's column
A summarized footer row in a grid
Multiple grids on one page
Summary
Chapter 7: Working on the User Interface
Using Gii to generate CRUD
Customize JavaScript and CSS
Using AJAX
Using the Bootstrap widget
Multiple models in the same view
Saving linked models in the same view
Summary
Chapter 8: Log in to the App
Creating a user login
Configuring user authorization
Mixing ACF and RBAC
Summary
Chapter 9: Frontend to Display Rooms to Everyone
Using an advanced template to split frontend and backend
Configuring an application using init
Sharing ActiveRecord models among applications
Customizing a URL in the advanced template
How to use the advanced template in the shared hosting
Summary
Chapter 10: Localize the App
Setting the default language
File-based translations
Placeholders formatting
DB-based translations
Summary
Chapter 11: Creating an API for Use in a Mobile App
Configuring a REST app in the advanced template
Creating a controller
Authentication
New controller action
Customizing authentication and response
Other forms of export – RSS
Summary
Chapter 12: Create a Console Application to Automate the Periodic Task
Interacting with console applications
Creating a console controller
Formatting the output from the console
Implementing and executing cron jobs
Summary
Chapter 13: Final Refactoring
Creating widgets
Creating components
Creating modules
Generating an API documentation
Summary

Book Details

ISBN 139781785287411
Paperback344 pages
Read More
From 1 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
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
Oracle 10g/11g Data and Database Management Utilities Book Cover
Oracle 10g/11g Data and Database Management Utilities
$ 29.99
$ 21.00