Kohana 3.0 Beginner’s Guide


Kohana 3.0 Beginner’s Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • The first and only book on the Kohana 3 PHP framework.
  • Covers all major areas needed to begin developing web applications with Kohana
  • Covers complete development cycle from installation to deployment
  • Easy to follow instructions that help you build a working example application during the course of the book

Book Details

Language : English
Paperback : 344 pages [ 235mm x 191mm ]
Release Date : August 2011
ISBN : 184951240X
ISBN 13 : 9781849512404
Author(s) : Jason D. Straughan
Topics and Technologies : All Books, Web Development, Beginner's Guides, Open Source

Table of Contents

Preface
Chapter 1: Getting Started
Chapter 2: Using Views and Controllers
Chapter 3: Routing and Request Handling
Chapter 4: Working with Helpers and Classes
Chapter 5: Installing and Configuring Modules
Chapter 6: Interacting with the Database
Chapter 7: Using the ORM and Auth Modules
Chapter 8: Troubleshooting and Error Handling
Chapter 9: Securing and Deploying Kohana 3
Appendix: Upgrading from CodeIgniter and Kohana 2
Index
  • Chapter 1: Getting Started
    • System requirements
    • Case Study
    • Downloading and installing from the Web
    • Time for action – Downloading from web
    • Installing Kohana from GitHub
    • Time for action – downloading using Git
      • Advanced installation with Git
      • Taking inventory
      • Preparing the Filesystem
    • Testing the environment
    • Configuring Kohana for Development Environment
    • Time for action – Setting your Timezone
      • Configuring URL settings
    • Time for action – setting base URL
      • Setting up the Application Environment
    • Time for action – Setting Kohana::$environment
      • Enabling modules
    • Time for action – Enabling the User Guide
      • Creating a default config file
      • Server configuration
        • Configuring Apache
        • Configuring nginx
    • Testing your configuration
    • Summary
    • Chapter 2: Using Views and Controllers
      • What are controllers and views?
        • Anatomy of a view
        • Anatomy of a controller
      • Updating our Welcome Controller
      • Time for action – Getting our controller action to use a view file
      • Passing data to the view
        • Using the factory( ) method
      • Time for action – Passing data via the factory method
        • Using view variables
      • Time for action – Passing data as view variables
        • Using the set( ) method
      • Time for action – Passing data using the set() method
        • Using the bind( ) method
      • Time for action – Passing data using the bind( ) method
        • Putting it all together
      • Time for action – Passing data using multiple methods
      • Using the Template Controller
      • Time for action – Extending Kohana's Template Controller
        • Examining the Template controller
        • Setting global view variables
      • Time for action – Setting global view variables
        • Binding global view variables
      • Time for action – Binding global view variables
        • Beyond the Welcome Controller
      • Creating new controllers
      • Time for action – Creating our first controller
      • Time for action – Expanding on our first controller
      • Creating a base controller
      • Time for action – Creating an abstract controller
      • Putting it all together
      • Time for action – Adding stylesheets to template
        • Adding structure to view files
      • Time for action – Adding header and footer view files
      • Summary
      • Chapter 3: Routing and Request Handling
        • Hierarchy is King in Kohana
          • Cascading filesystem
        • Request flow in Kohana
        • Using the Request object
          • Creating a profile page to render messages
        • Time for action – Creating a profile page with messages
          • Calling a new request inside a request
        • Time for action – Creating a request within a request
        • Routing in Kohana
        • Time for action – Making profiles dynamic using ID
          • Creating friendly URLs using custom routes
        • Time for action – Creating a Custom Route
          • Making routes explicit
        • Time for action – Adding regex to a route
          • Allowing additional data in a URI
        • Time for action – Allowing additional segments in a route
          • Using subdirectories with routes
        • Time for action – Using Subdirectories and Routes
        • Summary
        • Chapter 4: Working with Helpers and Classes
          • Autoloading classes
          • Introducing helpers
            • The Date class
            • The HTML Class
              • The HTML::chars() method
              • The HTML::obfuscate() method
              • The HTML::anchor() method
              • The HTML::image() method
              • The HTML::mailto() method
            • The Inflector Class
            • The URL class
              • The URL::title() method
              • The URL::base() method
              • The URL::query() method
            • The Arr (Array) Class
              • The Arr::get() method
              • The Arr::extract() method
              • The Arr::pluck() method
              • The Arr::merge() method
              • The Arr::overwrite() method
              • The Arr::flatten() method
              • The Arr::unshift() method
              • The Arr::map() method
              • The Arr::is_array() method
              • The Arr::range() method
            • The Cookie class
            • The Encrypt (Encryption) Class
          • Time for action – Creating configuration for Encryption
            • The Feed Class
            • The Form Class
          • Time for action – Creating a login form using the Form helper class
          • Time for action – Creating a signup form for new users
          • Extending Helpers
            • Transparent Class Extension
          • Time for action – Extending the HTML helper method
            • Creating your own helpers
          • Summary
          • Chapter 5: Installing and Configuring Modules
            • Anatomy of a Module
            • Loading and configuring modules
            • Bundled modules
              • User guide module
              • Image module
              • oAuth module
              • Database and ORM modules
            • Time for action – Configuring your application to use a database
            • Time for action – Creating a database table and using the query builder
              • Pagination module
            • Time for action – Adding pagination to database results
              • Auth module
              • Code Bench module
              • Cache and Unit Test modules
            • Installing modules
              • Installing modules from source files
            • Time for action – Installing a module from an archive
              • Installing modules via Git
            • Time for action – Installing a module using git
            • Creating your own modules
            • Summary
            • Chapter 6: Interacting with the Database
              • Anatomy of a model
                • Creating models
              • Using the Database module
                • Configuring the Database module
                • Creating and running queries
                • Using the Query Builder
                  • Select statements
                  • Using results
              • Time for action – Refactoring Model_Message to allow dynamic search
                • Insert statements
            • Time for action – Adding the ability to insert messages in case study site
              • Updating statements
            • Time for action – Add ability to edit messages in case study site
              • Delete statements
            • Time for action – Add ability to delete messages from the case study site
              • Other functions and expressions
            • Using the Database Module with sessions
              • Configuring database sessions
            • Time for action – Adding session handling with the database adapter
              • Using Database Sessions
            • Summary
              • Chapter 7: Using the ORM and Auth Modules
                • Using the ORM module
                  • Setting up the ORM module
                    • Convention over configuration
                    • ORM API Overview
                • Time for action – Updating Message Model to use ORM
                  • ORM, Forms, and Validation
                    • The Validation class
                • Time for action – Adding validation to Message Model
                  • ORM and Relational Data
                • Using the Auth module
                  • Configuring the Auth module
                • Time for action – Adding users and Auth to case study site
                  • Implementing the Auth module
                • Time for action – Adding the Auth functionality to the case study site
                  • Securing controllers and actions
                • Time for action – Adding secure actions to the case study site
                • Summary
                • Chapter 8: Troubleshooting and Error Handling
                  • Debugging code with Kohana
                    • Debugging with the Kohana class
                    • Error and exception handling
                  • Time for action – Adding error messages to signup form
                    • Disabling the error handler
                    • Viewing the error logs
                  • Handling 404 redirects
                  • Time for action – Adding a custom 404 page
                  • Profiling our applications
                  • Time for action – Adding profiling to the case study project
                  • Summary
                  • Chapter 9: Securing and Deploying Kohana 3
                    • Securing our applications
                      • XSS attacks
                    • Time for action – Securing against XSS risks
                      • SQL injection
                      • Cookies and sessions
                        • Securing cookies
                        • Securing sessions
                      • Configuring the application environment
                    • Preparing for production
                      • Removing unnecessary files
                      • Directory structure considerations
                        • Multiple Application Configuration
                      • Updating the Configuration settings
                    • Summary
                    • Appendix: Upgrading from CodeIgniter and Kohana 2
                      • What makes Kohana different from CodeIgniter?
                      • Moving from CodeIgniter to Kohana
                        • Autoloading classes
                        • Strict PHP 5 codebase
                        • Included ORM
                        • Modules
                      • Moving from Kohana 2.x
                        • GET and POST methods
                        • Directory structure
                        • Naming conventions
                        • Views
                        • Updated ORM
                        • Routing and requests
                      • Upgrading from Kohana 3.0 to 3.1
                        • Request and response classes
                        • Security enhancements
                        • Bootstrapping and the front controller
                        • Validation library
                        • Other changes

                      Jason D. Straughan

                      Jason D. Straughan is currently a software engineer at LiveOak 360, Inc., a web development firm with a focus on social networking and custom web applications. He is also a founding partner in Straughan Photography (SanAntonioWeddingPhotography.com) and provides consultation and training to a select number of clients through his web consulting firm. You can follow his blog, and read more about Kohana and web-related topics at http://www.JDStraughan.com
                      Sorry, we don't have any reviews for this title yet.

                      Code Downloads

                      Download the code and support files for this book.


                      Submit Errata

                      Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                      Errata

                      - 9 submitted: last submission 11 Nov 2013

                      Errata type: Typo | Page number: 20

                      The code:
                      $ cd public
                      $ mkdirjs
                      $ mkdircss
                      $ mkdir images

                      Should be:
                      $ cd public
                      $ mkdir js
                      $ mkdir css
                      $ mkdir images

                       

                      Errata type: Typo | Page number: 23

                      The code:
                      Kohana::init(array(
                      'base_url' => '/egotist/›,
                      ‹index_file› => ‹›
                      ));

                      Sould be:
                      Kohana::init(array(
                      'base_url' => '/egotist/',
                      'index_file' => ''
                      ));

                       

                      Errata type: Typo | Page number: 35

                      The line:
                      classController_Welcome extends Controller {
                      Should be:
                      class Controller_Welcome extends Controller {

                       

                      Errata type: Typo | Page number: 37

                      The line:
                      <p>This is thewelcome.php view</p>
                      Should be:
                      <p>This is the welcome.php view</p>

                       

                      Errata type: Typo | Page number: 39

                      The code:
                      $data = array();
                      $data[‹site_name›] = ‹Egotist›;
                      $data[‹random›] = rand(1,10);
                      $this->request->response = View::factory(‹welcome›, $data);

                      Should be:
                      $data = array();
                      $data['site_name'] = 'Egotist';
                      $data['random'] = rand(1,10);
                      $this->request->response = View::factory('welcome', $data);

                       

                      Errata type: Typo | Page number: 41

                      The line:
                      $view->site_name = ‹Egotist›;
                      Should be:
                      $view->site_name = 'Egotist';

                       

                      Errata type: Typo | Page number: 42

                      The code:
                      ->set(‹site_name›, ‹Egotist›)
                      ->set(‹random›, rand(1,10));

                      Should be:
                      ->set('site_name', 'Egotist')
                      ->set('random', rand(1,10));

                       

                      Errata type: Typo | Page number: 43

                      The code:
                      $view = View::factory(‹welcome›)
                      ->bind(‹site_name›, $site_name)
                      ->bind(‹random›, $random);
                      $site_name = ‹Egotist›;

                      Should be:
                      $view = View::factory('welcome')
                      ->bind('site_name', $site_name)
                      ->bind('random', $random);
                      $site_name = ‘Egotist’;

                       

                      Errata type: Typo | Page number: 24

                      The code:
                      if (isset($_SERVER['KOHANA_ENV'])) { Kohana::$environment = $_SERVER[‹KOHANA_ENV›]; } ,
                      ‹index_file› => ‹›
                      ));

                      Sould be:
                      if (isset($_SERVER['KOHANA_ENV'])) { Kohana::$environment = $_SERVER['KOHANA_ENV']; } ,
                      'index_file' => ''
                      ));

                       

                      Sample chapters

                      You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                      Frequently bought together

                      Kohana 3.0 Beginner’s Guide +    Working with OpenERP =
                      50% Off
                      the second eBook
                      Price for both: £24.65

                      Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                      What you will learn from this book

                      • Understand the HMVC architecture
                      • Learn Routing and Requesting handling in Kohana
                      • Create modules for extending your applications
                      • Interact with the Database and ORM classes to provide an object- oriented way of manipulating data
                      • Create helper classes to make your code fast to write and easy to use.
                      • Troubleshoot and debug your Kohana application
                      • Implement security and deployment best practices
                      • Migrate from Kohana 2.x or CodeIgniter

                      In Detail

                      Modern web development relies heavily on the ability to rapidly create applications that are reliable, maintainable, and scalable. The PHP-based Kohana framework has proven to be one of the best platforms for delivering professional quality applications using a stable framework that allows you to build great web properties while leveraging a rapid development architecture that is both powerful and intuitive.

                      Kohana 3 Beginner’s Guide is the first and only book in the market for learning about this popular and powerful open-source PHP framework. Written with the beginner in mind, this book walks you through installation and configuration, then uses a case study site to deliver real world solutions to common web development needs.

                      Beginning with the installation and configuration of the framework, you are guided through the steps necessary to get up and running, and are quickly introduced to the basics of Kohana.

                      Using a case study site as an example, the book illustrates core components of Kohana while showing elegant solutions to real world tasks developers face every day. From working with forms to databases, interacting with users to deploying applications in the wild, everything is covered in simple, easy to understand examples.
                      By the end of this book you will have mastered the core tasks needed to build great web applications using

                      A step-by-step guide to creating professional web applications using the Kohana framework.

                      Approach

                      This book follows the Beginner’s Guide approach, taking the reader from introduction to the framework through a working case study site. The text offers many examples of working code, and builds an entire test project during the course of the book. Although the chapters lend themselves to consecutive reading, you can pick up the book at any chapter without missing a beat.

                      Who this book is for

                      If you are a web developer who wants to create web applications using the Kohana 3 framework, then this book is for you. The book assumes that you have some experience with PHP and Object- Oriented Programming (OOP).

                      Code Download and Errata
                      Packt Anytime, Anywhere
                      Register Books
                      Print Upgrades
                      eBook Downloads
                      Video Support
                      Contact Us
                      Awards Voting Nominations Previous Winners
                      Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                      Resources
                      Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software