O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Yii Project Blueprints

Book Description

From conception to production, learn how to develop real-world applications with the Yii framework

In Detail

The Yii framework is a high-performance, fast, open source, and a rapid development PHP framework that can be used to develop modern web applications. It provides the toolkit for developing both personal projects and enterprise applications. Yii's component-based architecture lets developers build modules so that they aren't customizing the underlying code base and so that anything they build is easy to use in different projects.

This book is a step-by-step guide to developing reusable real-world applications using the Yii framework. The book will guide you through several projects from the project conception through to planning your project and implementation. You will explore the key features of the framework and learn how to use it efficiently and effectively to build solid core applications that you'll be able to reuse in real-world projects. At the end of each project, you'll have a better understanding of Yii and a working application that you can use in the future.

What You Will Learn

  • Organize and structure your projects from start to finish
  • Create applications from scratch and use Gii to create models
  • Use Yii database migrations to create database agnostic applications and manage your database changes
  • Create secure multiuser role-based applications that use Bcrypt password hashing
  • Integrate with third-party libraries using Composer
  • Develop console applications that seamlessly integrate with your applications
  • Utilize SendGrid to send and receive e-mails within your application

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Yii Project Blueprints
    1. Table of Contents
    2. Yii Project Blueprints
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. A Task-management Application
      1. Describing the project
        1. Tasks
        2. Projects
        3. Users
      2. The database
        1. The tasks table
        2. The projects table
        3. Users
        4. Choosing a database technology
          1. The tasks table
          2. The projects table
        5. The database overview
      3. Initializing the project
      4. Creating the database with migrations
      5. Creating models with Gii
        1. Enhancing the models
          1. Updating the default validation rules
          2. Defined relations
          3. Removing tasks when a project is deleted
          4. Retrieving the project metadata
          5. Automatically setting the created and updated time
      6. Creating the presentation layer
        1. Managing projects
          1. Creating the layout
          2. Creating the project index action
          3. Changing a project's completion state
          4. Deleting projects
          5. Creating and updating projects
          6. Viewing tasks
        2. Managing tasks
        3. Preventing unauthorized access to our application
          1. Requiring authentication with filters and access rules
          2. Creating a controller for the authentication
          3. Creating a login layout
          4. Creating a login view
          5. Identifying our users with the UserIdentity CUserIdentity class
          6. Creating the login model
      7. Finishing touches
        1. Disabling Gii
        2. Defining a default route
        3. Adding extra routes
      8. Summary
    9. 2. Discovering What's Nearby
      1. Describing the project
        1. Searching nearby locations
        2. Showing locations
        3. Storing locations
        4. Importing locations
      2. Designing the database
        1. Locations
      3. Initializing the project
        1. Creating the configuration file
        2. Retrieving the sample data
      4. Creating the database
      5. Creating the locations model
      6. Importing the data feed
      7. Google APIs
        1. Enabling Google APIs
        2. Generating an API key
        3. Storing the API key
      8. Creating the presentation layer
        1. Interacting with the Google Maps JavaScript API
        2. Searching nearby locations
        3. Selecting a location
        4. Showing locations on a map
        5. Optimizing the performance with caching
      9. Summary
    10. 3. Scheduled Reminders
      1. Prerequisites
      2. Describing the project
        1. Users
        2. Events
        3. Reminders
        4. The task runner
      3. Initializing the project
        1. Create a MySQL user and database
        2. Creating a Yii configuration file
        3. Creating a parameters configuration file
        4. Adding Composer dependencies
      4. Creating the database
        1. The users migration
        2. The reminders and events migration
      5. Creating models
        1. Model behaviors
        2. The Users model
          1. Bcrypt password hashing
        3. The Reminders model
        4. The Events model
      6. Searching for events and displaying them
        1. Custom routing for dates
        2. Creating the controller for events
        3. Creating the reminders controller
          1. Creating the layout
          2. Creating the main view
          3. Creating the item view
          4. Creating the event list view
          5. Creating and saving events
      7. Creating the controller to manage users
        1. Creating users
        2. Deleting users
        3. Changing the user's password
        4. Authenticating with Bcrypt
        5. Requiring authentication
      8. Sending e-mail reminders
      9. Summary
    11. 4. Developing an Issue-tracking Application
      1. Prerequisites
      2. Describing the project
        1. Users
          1. Roles
        2. Issues
          1. Statuses
          2. Updates
        3. Receiving e-mails
      3. Initializing the project
      4. Managing users
        1. Roles and authentication
        2. Listing users
        3. Deleting users
        4. Creating and updating users
        5. Viewing users and associated issues
      5. Implementing the issue-management component
        1. The Issues model
        2. The Issues Update model
        3. Showing issues that belong to the user
        4. Searching for issues
        5. Creating issues
        6. Viewing and updating issues
        7. E-mail views
        8. Testing our application
      6. Handling inbound e-mail parsing
        1. Sending e-mails to SendGrid
        2. Adjusting SendGrid Parse settings
        3. Creating and updating issues over e-mail
      7. Summary
    12. 5. Creating a Microblogging Platform
      1. Prerequisites
      2. Describing the project
        1. Users
      3. Initializing the project
        1. Making a better Yii bootstrap file
      4. Enabling users to manage their information
        1. Upgrading our UserIdentity class
        2. Defining user relations
          1. Determining whether a user is following another user
        3. Implementing a secure registration process
        4. Handling forgotten passwords
        5. Resetting a forgotten password
        6. Enabling users to manage their details
        7. Verifying a new e-mail address
      5. Viewing a timeline of shares
        1. Retrieving shares
      6. Sharing new content
        1. Resharing
        2. Liking and unliking shares
        3. Viewing shares
      7. Searching for shares
      8. Sharing on Twitter with HybridAuth
        1. Setting up a Twitter application
        2. Configuring HybridAuth
        3. Implementing HybridAuth social sign-on and sharing
      9. Summary
    13. 6. Building a Content Management System
      1. Prerequisites
      2. Describing the project
        1. Users
        2. Content
        3. Categories
        4. Search engine optimizations
      3. Initializing the project
      4. Exploring the skeleton project
        1. Extending models from a common class
        2. Creating a custom validator for slugs
        3. View management with themes
        4. Truly dynamic routing
          1. Telling Yii to use our custom UrlManager
      5. Displaying and managing content
        1. Rendering the sitemap
        2. Displaying a list view of content
        3. Displaying content by ID
          1. Adding comments to our CMS with Disqus
        4. Searching for content
        5. Managing content
      6. Viewing and managing categories
        1. Viewing entries in a category
          1. Viewing an RSS feed for categories
        2. Managing categories
      7. Social authentication with HybridAuth
        1. Validating remote identities
          1. Remote registrations
          2. Linking a social identity to an existing account
          3. Authenticating with a social identity
          4. Creating a Yii CWebUser object from a remote identity
        2. Putting it all together
          1. Exploring other HybridAuth providers
      8. Summary
    14. 7. Creating a Management Module for the CMS
      1. Prerequisites
      2. What are modules?
      3. Describing the project
        1. Initializing the module
        2. Routing with a module
        3. Moving the management functionality into the module
        4. Adding file upload capabilities
        5. Deploying modules
      4. Initializing the project
      5. Creating the module
        1. Registering the module with Yii
      6. Adding custom routes to a module
      7. Creating the controllers
      8. Migrating the functionality to the module
        1. Migrating content management
        2. Migrating categories
        3. Implementing user management
      9. Uploading files
        1. Creating the File class
        2. Creating the FileUploader class
        3. Creating the FileUpload class
        4. Creating the controller for the file manager
      10. Strategies for deploying our application
        1. Deploying as the application
        2. Deploying as a submodule
        3. Deploying as a Composer dependency
      11. Summary
    15. 8. Building an API for the CMS
      1. Prerequisites
      2. Describing the project
        1. Configuring the module
        2. Extending Yii to render JSON or XML in a RESTful way
        3. Handling data input
        4. Authenticating users to the API
        5. Handling API exceptions
        6. Handling data responses
        7. Implementing actions
      3. Initializing the project
      4. Extending Yii to return data
        1. Rendering data
        2. Calling actions in a RESTful way
        3. Authenticating users
          1. Overloading CAccessControlFilter
        4. Processing the incoming data
        5. Handling errors
          1. Exception handling
          2. Custom error handling
        6. Testing whether everything works
      5. Authenticating users
        1. Testing the authentication
        2. Sending authenticated requests
      6. Implementing CRUD actions
        1. Deleting users
        2. Retrieving users
        3. Creating and updating users
        4. Implementing other controller actions from the main application
        5. Implementing categories and content API controllers
        6. Documenting our API
      7. Summary
    16. Index