You are previewing FuelPHP Application Development Blueprints.
O'Reilly logo
FuelPHP Application Development Blueprints

Book Description

Supercharge your projects by designing and implementing web applications with FuelPHP

In Detail

FuelPHP is an open source framework that uses some of the most advanced features of PHP to allow you to build projects as easily and quickly as possible. It is gaining popularity with developers as you can build powerful, complex, and yet efficient applications with very little code.

This book will provide you with the skills you need to successfully create, improve, and publish functional and maintainable FuelPHP applications. We will go through a variety of topics such as MVC, ORM, scaffolding, packages, modules, and much more by building applications of increasing complexity. At the beginning of each chapter, we will specify the application we want to build, and then we will progressively implement it by learning new FuelPHP’s features along the way. By the end of the book, you will be familiar with FuelPHP and will be able to implement new projects all by yourself.

What You Will Learn

  • Use FuelPHP's ORM to your advantage to execute complex operations in the database using simple and object-oriented code

  • Implement clean and maintainable HMVC web applications using controllers, views, models, and presenters

  • Create modules and packages in order to implement reusable code bundles

  • Implement tasks to execute repetitive actions or cron jobs

  • Use the oil console to quickly test code and ideas

  • Create a powerful API-driven application in order to allow users and external services to use your data

  • Debug and profile your applications for further improvements

  • Be introduced to the Novius OS Content Management System based on FuelPHP

  • 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 If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. FuelPHP Application Development Blueprints
      1. Table of Contents
      2. FuelPHP Application Development Blueprints
      3. Credits
      4. About the Author
      5. About the Reviewers
        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. Building Your First FuelPHP Application
        1. About FuelPHP
        2. Development process of a FuelPHP application
        3. Installing the environment
          1. Windows
          2. Mac
          3. Ubuntu
          4. Recommended modules and extensions
          5. Getting the FuelPHP framework
          6. Installing FuelPHP 1.7.2
            1. Downloading the appropriate ZIP file
            2. Using Composer
          7. Updating FuelPHP
          8. Installation directory and apache configuration
            1. The simplest way
            2. By setting up a virtual host
        4. FuelPHP basics
          1. The FuelPHP file system hierarchy
            1. The app directory
            2. The packages
            3. Class name, paths, and coding standard
          2. MVC, HMVC, and how it works on FuelPHP
            1. What is MVC?
            2. How it works on FuelPHP
              1. Actions and controllers
              3. Parameters
              4. Routes
              5. Presenters
            3. What is HMVC?
          3. The oil utility and the oil console
        5. Building your first application
          1. Database configuration
          2. Scaffolding
          3. Migrating
          4. Using your application
          5. Refining the application
            1. Refining the monkey listing
            2. Refining the monkey detailed view
            3. Allowing an empty description
            4. Checking whether the height is a float
            5. Using a checkbox instead of an input for the still_here attribute
            6. Setting custom routes
            7. Removing useless routes and files
        6. A few notes about deploying your application
        7. Summary
      9. 2. Building a To-do List Application
        1. Specifications
        2. Conception
        3. FuelPHP installation and configuration
        4. Scaffolding
        5. Routes configuration
        6. The profiler
        7. Models, relations, and the ORM
          1. Differences between CRUD and ORM
          2. The FuelPHP ORM
            1. DB and ORM basics
              1. Executing queries without the ORM
              2. Creating new objects
              3. Finding specific objects
              4. Updating an object
              5. Deleting an object
              6. Loading several objects
              7. Using method chaining
              8. More complex requests
            2. ORM relations
              1. Defining relations inside the models
              2. Testing the relations
                1. Getting objects' relations
                2. Updating objects' relations
            3. Observers and events
        8. Implementation of the to-do list
          1. Allowing the user to see and change tasks' status
          2. Allowing the user to add tasks
          3. Allowing the user to change tasks' order
          4. Axis of improvements
        9. Summary
      10. 3. Building a Blog Application
        1. Specifications
        2. Conception
        3. Preliminary steps
        4. Scaffolding the posts
        5. Migrating part 1
        6. The administration panel
        7. The Auth package
        8. Creating the Blog module
          1. Moving files to the Blog module
          2. Improving the navigation bar
        9. Scaffolding the rest of our project
          1. Scaffolding categories
            1. Generating files
            2. Moving categories to the blog module
            3. Migrating
          2. Scaffolding comments
          3. Scaffolding posts (front)
        10. Refining the administration panel
          1. Refining the posts administration panel
            1. Improving the post creation and edition forms
              1. Removing and automatically filling the slug
              2. Changing the small description input to a textarea
              3. Editing the post content using a WYSIWYG editor
              4. Replacing the category input by a select box
              5. Replacing the user_id field by author
              6. Removing the View link
            2. The posts' list
              1. Removing the Slug, Small description and Content columns
              2. Displaying the category and author names
              3. Removing the view link
          2. Refining the categories administration panel
            1. Removing the View link
            2. Adding the number of post's column
              1. Solution 1: using count
              2. Solution 2: using related
              3. Solution 3: using DB::query
          3. Refining the comments administration panel
            1. Improving the comments listing
              1. Removing the view and adding a new comment link
              2. Removing the Email and Content columns
              3. Replacing the Post id column by Post
            2. Improving the comment edition form
              1. Changing the Status input to a select box
              2. Replacing Post id by Post
              3. Removing the View link
          4. Protecting your website against CSRF attacks
            1. Protecting links
            2. Protecting forms
        11. Refining the front-end
          1. Refining the posts' listing
            1. Deleting useless features
            2. Changing how the posts' listing is displayed
            3. Adding pagination
            4. Using posts' slug
            5. Listing posts by categories
            6. Adding indexes
          2. Refining the posts' visualization webpage
            1. Changing the post layout
            2. Adding the comment form
            3. Displaying comments
            4. Notifying the author when a new comment is posted
        12. Clearing rejected comments
        13. Additional improvements
        14. Summary
      11. 4. Creating and Using Packages
        1. What are CAPTCHAs?
        2. Preliminary steps
        3. Generating the sample application
        4. The reCAPTCHA solution
          1. Installing the recaptcha package
          2. Configuring the recaptcha package
          3. Integrating the recaptcha package
        5. Creating your own package
          1. Conception
          2. Generating the package
          3. Generating the Captcha_Answer model
          4. Migrating the package
          5. Integrating the package into our application
          6. Implementing the get_html method
          7. Implementing the CAPTCHA verification method
          8. Cleaning old captchas
          9. Possible improvements
        6. Summary
      12. 5. Building Your Own Restful API
        1. Specifications
        2. Conception
        3. FuelPHP installation and configuration
        4. The Parser package and template engines
        5. A major benefit of language-agnostic template engines
        6. Subscription and authentication features
          1. Implementing the subscription and authentication forms
          2. Handling the signup form
          3. Handling the signin form
          4. Allowing the user to sign out
        7. Allowing the user to create and view posts
          1. Generating the Post model
          2. Allowing the user to create new posts
            1. Implementing the user interface
            2. Implementing the post creation action
          3. Implementing the profile page
            1. Configuring the routes
            2. Creating the user model
            3. Implementing the show action
            4. Implementing views
          4. Implementing the API
            1. Implementing the base controller
            2. Implementing your first hybrid action
            3. Implementing mappers to control how the information is shared
          5. Improving the listing
            1. Giving JavaScript access to our Mustache views
              1. Generating the templates.js file
                1. The easy and dirty way
                2. Using guard-templates
              2. Integrating template.js and Mustache.js
            2. Implementing the post/list action
            3. Implementing the See more button
            4. Redirecting the home page to the logged user's web page
        8. Unit tests
        9. Possible improvements
        10. Summary
      13. 6. Building a Website Using Novius OS
        1. About Novius OS
        2. Getting Novius OS
        3. Configuring Novius OS
        4. Exploring Novius OS
          1. The applications manager
          2. The Novius OS desktop
          3. Novius OS' front and the default homepage
          4. The Webpages application
          5. Novius OS templates
          6. The App Desk
          7. Inserting enhancers in your webpages
        5. The Novius OS file system hierarchy
          1. Applications folder structure
          2. Files extensions
          3. Configurations and classes
        6. Creating an application
          1. Installing the 'Build your app' wizard
          2. Generating the application
          3. Testing your generated application
          4. Application basics
            1. The metadata configuration file
            2. The migration files
            3. The App desk
            4. The edition and creation forms
            5. The front controller
        7. More about Novius OS
        8. Summary
      14. Index