Managing Applications in CodeIgniter

13
Managing Applications in CodeIgniter Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com [email protected] @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program

Transcript of Managing Applications in CodeIgniter

Page 1: Managing Applications in CodeIgniter

Managing Applications in CodeIgniter

Jamshid HashimiTrainer, Cresco Solution

http://www.jamshidhashimi.com [email protected] @jamshidhashimi ajamshidhashimi

Afghanistan Workforce Development Program

Page 2: Managing Applications in CodeIgniter

Agenda

• Managing Applications• Handling Multiple Environments• Security• PHP Style Guide

Page 3: Managing Applications in CodeIgniter

Managing Applications

• By default it is assumed that you only intend to use CodeIgniter to manage one application, which you will build in your application/ directory. It is possible, however, to have multiple sets of applications that share a single CodeIgniter installation.

Page 4: Managing Applications in CodeIgniter

Managing Applications

• Renaming application folder – index.php

• Relocating your Application Folder

$application_folder = "application";

$application_folder = "/Path/to/your/application";

Page 5: Managing Applications in CodeIgniter

DEMO

Page 6: Managing Applications in CodeIgniter

Handling Multiple Environments

• Developers often desire different system behavior depending on whether an application is running in a development or production environment. – Development– Testing– Production

Page 7: Managing Applications in CodeIgniter

Security

• URIs may only contain the following:– Alpha-numeric text– Tilde: ~– Period: .– Colon: :– Underscore: _– Dash: -

• Register Globals– During system initialization all global variables are unset, except

those found in the $_GET, $_POST, and $_COOKIE arrays. – register_globals = off.

Page 8: Managing Applications in CodeIgniter

Security• error_reporting• magic_quotes_runtime• Best Practices

– Filter the data as if it were tainted.• XSS Filter - CodeIgniter comes with a Cross Site Scripting filter.

– Validate the data to ensure it conforms to the correct type, length, size, etc. • CodeIgniter has a Form Validation Class that assists you in validating, filtering,

and prepping your data.

– Escape the data before submitting it into your database.• Escape all data before database insertion• $this->db->escape()• $this->db->escape_str()• $this->db->escape_like_str()

Page 9: Managing Applications in CodeIgniter

PHP Style Guide

• File Format– UTF8

• PHP Closing Tag• Class and Method Naming• Variable Names• Commenting• Constants• TRUE, FALSE, and NULL• Logical Operators• Comparing Return Values and Typecasting

Page 10: Managing Applications in CodeIgniter

PHP Style Guide

• Debugging Code• Whitespace in Files• Compatibility• Class and File Names using Common Words• Database Table Names• One File per Class• Whitespace• Line Breaks– Unix– Windows

Page 11: Managing Applications in CodeIgniter

PHP Style Guide

• Code Indenting• Bracket and Parenthetic Spacing• Localized Text• Private Methods and Variables• PHP Errors• Short Open Tags• One Statement Per Line• Strings• SQL Queries• Default Function Arguments

Page 12: Managing Applications in CodeIgniter

DEMO

Page 13: Managing Applications in CodeIgniter

QUESTIONS?