Phpconf 2011 introduction_to_codeigniter

  • Published on
    10-Aug-2014

  • View
    8.058

  • Download
    25

DESCRIPTION

http://phpconf.tw/2011 CodeIgniter (Bo-Yi Wu)/appleboy Introduction to CodeIgniter

Transcript

CodeIgniter Bo-Yi Wu appleboy http://blog.wu-boy.com/ 2011.11.12 2011 PHP Conference CC 3.0 $this->load->view(about/me) Linux Kernel Driver, Sencha Touch Web App. CodeIgniter http://codeigniter.org.tw Patch CodeIgniter Github https://github.com/appleboy2011/11/12 PHP Conference 3 Framework PHP Web Developer2011/11/12 PHP Conference 4 Why use Framework? ( Soho) ( , , ) ($_GET, $POST ...)2011/11/12 PHP Conference 5 CodeIgniter 2009 1 1 2011/11/12 PHP Conference 6 (Zend, Cake, Symfony, Yii...)2011/11/12 PHP Conference 7 $this->load->view(Why) Framework CodeIgniter2011/11/12 PHP Conference 8 CodeIgniter MVC ( Framework)2011/11/12 PHP Conference 9 2011/11/12 PHP Conference 10 + = 2011/11/12 PHP Conference 11 ? http://www.codeigniter.org.tw/downloads unzip CodeIgniter_2.X.X.zip http://your_host_name/codeigniter/2011/11/12 PHP Conference 12 $this->load->view(welcome)2011/11/12 PHP Conference 13 2011/11/12 PHP Conference 14 PHP ( )2011/11/12 PHP Conference 15 CodeIgniter 2011/11/12 PHP Conference 16 CodeIgniter application ( ) system (CodeIgniter ) user_guide (CodeIgniter ) index.php ( )2011/11/12 PHP Conference 17 ( Framework )2011/11/12 PHP Conference 18 system ( ) web_01 application index.php web_02 application index.php2011/11/12 PHP Conference 19 ( ) http://codeigniter.org.tw/user_guide/2011/11/12 PHP Conference 20 2011/11/12 PHP Conference 21 CodeIgniter URLs Database (Controllers) Input (Views) Loader (Models)2011/11/12 PHP Conference 22 (Library) Email File Uploading Hooks Form Validation URI Language Output Pagination Session 2011/11/12 PHP Conference 23 2011/11/12 PHP Conference 24 CodeIgniter MVC 2011/11/12 PHP Conference 25 MVC Architecture Database Layout Model Library Helper View Controller Routing Caching Web Server2011/11/12 Client Browser PHP Conference 26 Hello World2011/11/12 PHP Conference 27 Hello Appleboy View (views/welcome.php) View Hello Controller (controllers/welcome.php) function welcome($id) {Controller $data[username] = $id; $this->load->view(welcome, $data); }2011/11/12 PHP Conference 28 CodeIgniter 2011/11/12 PHP Conference 29 URL Apache mod_rewrite URL 2011/11/12 PHP Conference 30 CodeIgniter URL $route[products/([a-z]+)/(d+)] = "$1/id_$2" products/os/1234 os controller id_1234 $route[(:any)] = "system/fix" $route[.*] = system/fix2011/11/12 PHP Conference 31 High Performance Framework CodeIgniter 2011/11/12 PHP Conference 32 High Performance Framework Library $this->load->library(array(email, table)); view $this->load->view(file_name); model $this->load->model(model_name); helper $this->load->helper(help_name);2011/11/12 PHP Conference 33 CodeIgniter Cahe System index Cache Routing Caching Application Controller2011/11/12 PHP Conference 34 Cache Cache Controller $this->output->cache(n); n 2011/11/12 PHP Conference 35 Cache expire time 2011/11/12 PHP Conference 36 CodeIgniter Cache time()+n*60 cache Request time() cache time > time() cache file cache time < time() cache cache : 2011/11/12 PHP Conference 37 ? cache Patch http://goo.gl/03IrZ $this->output->delete_cache(post/12) $this->output->delete_cache(post/list)2011/11/12 PHP Conference 38 Command Line CodeIgniter 2.x.x Windows, Linux crontab 2011/11/12 PHP Conference 39 CLI cron-jobs curl "tasks" , cache , Perl, C++, Python2011/11/12 PHP Conference 40 $ php index.php controller method$ php index.php welcome index2011/11/12 PHP Conference 41 command line corn-jobs apache PHP cron-jobs php_sapi_name() === "cli" defined(STDIN)2011/11/12 PHP Conference 42 $_POST,$_GET if ( ! isset($_POST[user])) $user = FALSE; else $user = $_POST[user];$user = (! isset($_POST[user])) ? FALSE : $_POST[user]; 2011/11/12 PHP Conference 43 $_POST $user = $this->input->post(user); $_GET $user = $this->input->get(user); $user = $this->input->get_post(user); $_POST[user], $_GET[user]2011/11/12 PHP Conference 44 XSS $user = $this->input->post(user, TRUE); $user = $this->input->get(user, TRUE); $user = $this->input->get_post(user, TRUE);2011/11/12 PHP Conference 45 === intval() (int) $id = intavl($id); $id = (int) $id; is_array, is_int, is_bool, is_string 2011/11/12 PHP Conference 46 $this->form_validation->set_rules(username, , trim|required|min_length[5]|max_length[12]| xss_clean); $this->form_validation->set_rules(password, , trim|required|md5); $this->form_validation->set_rules(email, , trim|required|valid_email); 2011/11/12 PHP Conference 47 $this->load->library(pagination); $config[base_url] = http://example.com/index.php/test/page/; $config[total_rows] = 200; $config[per_page] = 20; $this->pagination->initialize($config); echo $this->pagination->create_links();2011/11/12 PHP Conference 48 Email : Mail Sendmail and SMTP (CC) (BCCs) HTML (Plaintext) 2011/11/12 PHP Conference 49 $this->load->library(email); $this->email->from(your@example.com, Your Name); $this->email->to(someone@example.com); $this->email->cc(another@another-example.com); $this->email->bcc(them@their-example.com); $this->email->subject(Email Test); $this->email->message(Testing the email class.); $this->email->send(); echo $this->email->print_debugger(); 2011/11/12 PHP Conference 50 GD/GD2 NetPBM ImageMagick2011/11/12 PHP Conference 51 CodeIgniter Library User Guide http://goo.gl/7PGnW2011/11/12 PHP Conference 52 CodeIgniter 2011/11/12 PHP Conference 53 http://getsparks.org/2011/11/12 PHP Conference 54 What is Sparks? Ruby RubyGems Node.js npm CodeIgniter sparks2011/11/12 PHP Conference 55 What is Sparks? Package Management System Making Code Easy to Find, Create, and Distribute2011/11/12 PHP Conference 56 Get Sparks tool Now!! $ php -r "$(curl -fsSL http://getsparks.org/go-sparks)" 2011/11/12 PHP Conference 57 Installing Sparks with the Spark Manager http://goo.gl/lHmCX$ php tools/spark install -v1.0.4 google-url-shortener 2011/11/12 PHP Conference 58 Load Sparks Library$this->load->spark(google-url-shortener/1.0.4);$short_url = $this->google_url_api->shorten($url);echo $url . " => " . $short_url->id . "";2011/11/12 PHP Conference 59 sparks ion_auth http://goo.gl/Au4kM E-mail , .. User/Email Zend ACL Library Facebook, Google Auth API Template http://goo.gl/BN5g6 CSS Javascript2011/11/12 PHP Conference 60 CodeIgniter 2009->2011 1.7.x 2.x.x PHP4 Bitbucket Github 2011/11/12 PHP Conference 61 http://www.codeigniter.org.tw/forum/2011/11/12 PHP Conference 62 CodeIgniter 2011/11/12 PHP Conference 63 https://github.com/appleboy/PHP-CodeIgniter-Framework-Taiwan : http://goo.gl/5CU9N 2011/11/12 PHP Conference 64 Thank You.2011/11/12 PHP Conference 65