+ All Categories
Home > Education > CodeIgniter Lab

CodeIgniter Lab

Date post: 16-May-2015
Category:
Upload: leo-nguyen
View: 472 times
Download: 5 times
Share this document with a friend
Description:
CodeIgniter Lab http://leonguyen.com
Popular Tags:
54
LeoNguyen.com
Transcript
Page 2: CodeIgniter Lab

Outline

- Lab 01: Introduction CodeIgniter 2.1.3- Lab 02: HMVC- Lab 03: Grocery CRUD 1.3.3- Lab 04: Eden Library 3.1- Lab 05: Doctrine 2

Page 3: CodeIgniter Lab

References

- net.tutsplus.com- PHP Academy (http://bit.ly/14h0dTL, http://bit.ly/13QbLhU, http://bit.ly/15ovBwq)- Shawn McCool (http://bit.ly/13lLpRM)- VideoTutorialsWatch (http://bit.ly/1br4wil)- PHP and Stuff (www.phpandstuff.com)

Page 4: CodeIgniter Lab

Github

https://github.com/leonguyen/CILab

Page 5: CodeIgniter Lab

Lab 01

Introduction to CodeIgniter

Page 6: CodeIgniter Lab

Outline

- Download and config CI- Write a Hello world program

Page 7: CodeIgniter Lab

Exercise 1

Download and config CI

Page 8: CodeIgniter Lab

CodeIgniter

Page 10: CodeIgniter Lab

Task 2 - Unzip CI

- Unzip CI zip file.

Page 11: CodeIgniter Lab

Task 3 - Download & install Sublime Text

- Goto Sublime Text download site http://www.sublimetext.com

Page 12: CodeIgniter Lab

Task 4 - Config autoload.php

- Enter code: https://gist.github.com/leonguyen/5315988

Page 13: CodeIgniter Lab

Task 5 - Config config.php

- Enter code: https://gist.github.com/leonguyen/5315997

Page 14: CodeIgniter Lab

Task 6 - Config database.php

- Enter code: https://gist.github.com/leonguyen/5316010

Page 15: CodeIgniter Lab

Task 7 - Run CI

- Enter the url http://localhost/cilab/ on the browser.

Page 16: CodeIgniter Lab

Task 8 - Userguide CI

- Enter the url http://localhost/cilab/user_guide/ on the browser.

Page 17: CodeIgniter Lab

Exercise 2

Write a Hello world program

Page 18: CodeIgniter Lab

Task 1 - Create Helloworld controller

- Copy Welcome controller, enter the following code then goto http://localhost/cilab/index.php/helloworld

Page 19: CodeIgniter Lab

Task 2 - Create .htaccess

- Create .htaccess in root source files then enter the following code:https://gist.github.com/leonguyen/5251416

Page 20: CodeIgniter Lab

Task 3 - Config config.php

- Remove 'index.php' of 'index_page'.- Enter 'QUERY_STRING' of 'uri_protocol'.

Page 21: CodeIgniter Lab

Task 4 - Run again

- Goto http://localhost/cilab/helloworld.

Page 22: CodeIgniter Lab

Lab 02

HMVC (Hierarchical Model View Controller)

Page 23: CodeIgniter Lab

HMVC

Page 24: CodeIgniter Lab

HMVC (cont)

- Modularization: Reduction of dependencies between the disparate parts of the application.- Organization: Having a folder for each of the relevant triads makes for a lighter work load.- Reusability: By nature of the design it is easy to reuse nearly every piece of code.- Extendibility: Makes the application more extensible without sacrificing ease of maintenance.

Page 25: CodeIgniter Lab

Outline

- Download and config HMVC modular.- Create sample 'Foo' modules.

Page 26: CodeIgniter Lab

Exercise 1

Download and config HMVC modular

Page 27: CodeIgniter Lab

Task 1: Download HMVC Modular

- Goto https://bitbucket.org/wiredesignz and download "codeigniter-modular-extensions-hmvc"

Page 28: CodeIgniter Lab

Task 2: Copy 'MX' third_party

- Copy 'MX' folder to 'third_party' folder of CI.

Page 29: CodeIgniter Lab

Task 3: Copy to 'application/core'

- Copy 'MY_Loader.php' and 'MY_Router.php' to 'application/core'.

Page 30: CodeIgniter Lab

Exercise 2

Create sample 'Foo' modules

Page 31: CodeIgniter Lab

Task 1: Create 'modules' folder

- Create 'modules' folder in 'application' and 'Foo' modules.

Page 32: CodeIgniter Lab

Task 2: Create 'Foo' controller

- Create 'Foo' controller extends 'MX_Controller':https://gist.github.com/leonguyen/5326355

Page 33: CodeIgniter Lab

Task 3: Create 'Foo' controller

- Create 'Foo' controller extends 'MX_Controller'.

Page 34: CodeIgniter Lab

Lab 03

Grocery CRUD

Page 35: CodeIgniter Lab

Intro- Grocery CRUD is a library that makes a developer's life easier. Just few lines of code and you can create a full stable CRUD with nice views. A totally automatic system that even a newbie in PHP can work with.

Page 36: CodeIgniter Lab

Task 1: Download- Go to www.grocerycrud.com

Page 37: CodeIgniter Lab

Task 2: Installation- Unzip 'grocery_CRUD.zip' and copy all files to your CI project.

Page 38: CodeIgniter Lab

Task 3: Installation - MySQL- Import 'examples_database.sql' to your project mysql.

Page 39: CodeIgniter Lab

Task 4: Run- Enter the url http://localhost/CILab/examples/ on the browser.

Page 40: CodeIgniter Lab

Lab 04

Eden Library

Page 41: CodeIgniter Lab

Intro- Eden is a PHP library designed for rapid prototyping, with less code. Yes, Really.- Eden simply a set of reusable components, that works with any PHP framework and CMS. Eden makes code logical and readable with dead simple syntax.

Page 42: CodeIgniter Lab

Task 1: Download- Go to www.eden-php.com

Page 43: CodeIgniter Lab

Task 2: Installation- Unzip 'eden.zip' and copy all files to 'libraries' folder of your CI project.

Page 44: CodeIgniter Lab

Task 3: Create example controller- Create 'edenhellow.php' controller and enter code: https://gist.github.com/leonguyen/5915315

Page 45: CodeIgniter Lab

Task 4: Run- Enter the url http://localhost/CILab/edenhello/ on the browser.Note: You have access to a server with at least PHP 5.3.x

Page 46: CodeIgniter Lab

Lab 05

Doctrine 2

Page 47: CodeIgniter Lab

Intro- Doctrine is a very powerful ORM in php and it is possible to easily integrate and use doctrine with codeigniter as ORM

Page 48: CodeIgniter Lab

Task 1: Download- Go to github.com/doctrine and download+ ORM: github.com/doctrine/doctrine2+ Common: github.com/doctrine/common+ DBAL: github.com/doctrine/dbal and Cache, Annotations, Lexer

Page 49: CodeIgniter Lab

Task 2: Create Doctrine folder- Create ‘Doctrine’ folder into ‘application/libraries’ and put its files.

Page 50: CodeIgniter Lab

Task 3: Create Doctrine bootstrap- Create ‘Doctrine.php’ into ‘application/libraries’ folder.- Enter code: https://gist.github.com/leonguyen/6696118

Page 51: CodeIgniter Lab

Task 4: Load Doctrine- Modify the ‘autoload.php’

Page 52: CodeIgniter Lab

Task 5: Create YAML mapping files- Enter code: https://gist.github.com/leonguyen/6701457https://gist.github.com/leonguyen/6701498

Page 53: CodeIgniter Lab

Task 6: Command Line Tool- Create ‘doctrine-cli.php’ into ‘application’ folder.- Enter code: https://gist.github.com/leonguyen/6700705

Page 54: CodeIgniter Lab

Task 7: Setup Entities, Proxies, and DB Schema

- List of commands: php doctrine-cli.php(See: youtu.be/yFH5JcH-RtM)- Entity classes: php doctrine-cli.php orm:generate-entities models(See: youtu.be/nEMfBno40vE)- Proxy classes: php doctrine-cli.php orm:generate-proxies(See: youtu.be/v4J_cI5CJe0)- Drop tables: php doctrine-cli.php orm:schema-tool:drop --force(See: youtu.be/lhGWsFmCeoc)- Create tables: php doctrine-cli.php orm:schema-tool:create(See: youtu.be/MhLAi4f_mg4)


Recommended