Getting Started with Codeigniter 4 Codeigniter 4 at First Glance
Total Page:16
File Type:pdf, Size:1020Kb
2017 Getting Started with CodeIgniter 4 CodeIgniter 4 at first glance. Start learning how to start using some of the new features in CodeIgniter 4 a Special Thank you and all Credit goes to Kilishan of New Myth Media for all of his time and hard work on this CodeIgniter 4 Document. PDF file by Raymond King Custom Software Designers, LLC. ( InsiteFX ) 8/16/2017 Table of Contents NOTE: ......................................................................................................................................................................... 6 The articles in this document are based on unreleased, pre-alpha versions of the software and specifics may have changed. ..................................................................................................................... 6 This should not be used for a Production Website.................................................................................... 6 Requests and Responses In CodeIgniter 4 .................................................................................................... 7 At A Glance ........................................................................................................................................................... 7 IncomingRequest............................................................................................................................................. 7 Response ............................................................................................................................................................ 8 A Quick Example ................................................................................................................................................ 8 Content Negotiation in CodeIgniter 4 ...........................................................................................................11 What Is Content Negotiation? .....................................................................................................................11 A Quick Example ..............................................................................................................................................12 Dependency Injection in CodeIgniter 4 .......................................................................................................14 Why Is DI Important? .....................................................................................................................................14 The Rise and Fall of the Container ............................................................................................................16 Services ...............................................................................................................................................................17 A Quick Example ..............................................................................................................................................19 Coupling? ........................................................................................................................................................20 Routes in CodeIgniter 4 .....................................................................................................................................21 Route Basics ......................................................................................................................................................21 Module-like Functionality ...........................................................................................................................22 Closures ..............................................................................................................................................................22 Placeholders....................................................................................................................................................23 HTTP Verbs........................................................................................................................................................24 Generating standard Resource routes .....................................................................................................24 No More Magic ..................................................................................................................................................25 Groups .................................................................................................................................................................25 Environment Groups ...................................................................................................................................26 Redirect Old Routes........................................................................................................................................26 Using Routes In Views ...................................................................................................................................26 Named Routes ................................................................................................................................................27 Reverse Routing ............................................................................................................................................27 Global Options ..................................................................................................................................................28 Need More? Customize it ..............................................................................................................................28 Modules in CodeIgniter 4 ..................................................................................................................................29 Module/HMVC Support? ...............................................................................................................................29 Autoloading and Namespaces .....................................................................................................................29 A Quick Example ..............................................................................................................................................30 What About Non-Class Files? .......................................................................................................................32 Loading Helpers ............................................................................................................................................32 Loading Views................................................................................................................................................32 First Glimpse at CodeIgniter 4 Database Layer ........................................................................................34 What's the Same?.............................................................................................................................................34 What's different? .............................................................................................................................................34 Configuration .................................................................................................................................................34 Raw Queries ...................................................................................................................................................36 Saved Queries ................................................................................................................................................37 Query Builder ................................................................................................................................................38 What's Still Coming? .......................................................................................................................................39 CodeIgniter 4 HTTP Client ................................................................................................................................41 The CURLRequest Class .................................................................................................................................41 A Few Quick Examples ...................................................................................................................................42 A Single Call ...................................................................................................................................................42 Consuming an API........................................................................................................................................42 Submitting A Form .......................................................................................................................................43 Multitude of Options ....................................................................................................................................43 Getting Started With CodeIgniter 4 Pre-Alpha 1 ......................................................................................45 Download It .......................................................................................................................................................45 Look Around .....................................................................................................................................................45