Slide 1

Slide 1 text

LeoNguyen.com

Slide 2

Slide 2 text

Outline - References (http://bit.ly/1fofKSV) - 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

Slide 3

Slide 3 text

Github https://github.com/leonguyen/CILab

Slide 4

Slide 4 text

Lab 01 Introduction to CodeIgniter

Slide 5

Slide 5 text

Outline - Download and config CI - Write a Hello world program

Slide 6

Slide 6 text

Exercise 1 Download and config CI

Slide 7

Slide 7 text

CodeIgniter

Slide 8

Slide 8 text

Task 1 - Download CI - Goto CI download site http://ellislab.com/codeigniter/user- guide/installation/downloads.html

Slide 9

Slide 9 text

Task 2 - Unzip CI - Unzip CI zip file.

Slide 10

Slide 10 text

Task 3 - Download & install Sublime Text - Goto Sublime Text download site http://www.sublimetext.com

Slide 11

Slide 11 text

Task 4 - Config autoload.php - Enter code: https://gist.github.com/leonguyen/5315988

Slide 12

Slide 12 text

Task 5 - Config config.php - Enter code: https://gist.github.com/leonguyen/5315997

Slide 13

Slide 13 text

Task 6 - Config database.php - Enter code: https://gist.github.com/leonguyen/5316010

Slide 14

Slide 14 text

Task 7 - Run CI - Enter the url http://localhost/cilab/ on the browser.

Slide 15

Slide 15 text

Task 8 - Userguide CI - Enter the url http://localhost/cilab/user_guide/ on the browser.

Slide 16

Slide 16 text

Exercise 2 Write a Hello world program

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Task 3 - Config config.php - Remove 'index.php' of 'index_page'. - Enter 'QUERY_STRING' of 'uri_protocol'.

Slide 20

Slide 20 text

Task 4 - Run again - Goto http://localhost/cilab/helloworld.

Slide 21

Slide 21 text

Lab 02 HMVC (Hierarchical Model View Controller)

Slide 22

Slide 22 text

HMVC

Slide 23

Slide 23 text

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.

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Exercise 1 Download and config HMVC modular

Slide 26

Slide 26 text

Task 1: Download HMVC Modular - Goto https://bitbucket.org/wiredesignz and download "codeigniter- modular-extensions-hmvc"

Slide 27

Slide 27 text

Task 2: Copy 'MX' third_party - Copy 'MX' folder to 'third_party' folder of CI.

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Exercise 2 Create sample 'Foo' modules

Slide 30

Slide 30 text

Task 1: Create 'modules' folder - Create 'modules' folder in 'application' and 'Foo' modules.

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

Task 3: Create 'Foo' controller - Create 'Foo' controller extends 'MX_Controller'.

Slide 33

Slide 33 text

Lab 03 Grocery CRUD

Slide 34

Slide 34 text

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.

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

Lab 04 Eden Library

Slide 40

Slide 40 text

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.

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

Lab 05 Doctrine 2

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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)