{"id":730,"date":"2011-05-02T00:13:02","date_gmt":"2011-05-02T07:13:02","guid":{"rendered":"https:\/\/wordpress-1325650-4848760.cloudwaysapps.com\/?p=730"},"modified":"2025-05-24T12:14:39","modified_gmt":"2025-05-24T16:14:39","slug":"codeigniter-basic-tutorial","status":"publish","type":"post","link":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial","title":{"rendered":"Codeigniter Tutorial For Beginners: PHP Web Application Guide"},"content":{"rendered":"\n<p>Are you looking to build powerful PHP web applications but feeling overwhelmed by where to start? Well, I&#8217;ve got fantastic news for you! Codeigniter is absolutely the framework you need to master. I&#8217;ve been using it for years, and I can tell you firsthand that it&#8217;s one of the most beginner-friendly yet powerful PHP frameworks out there.<\/p>\n\n\n\n<p>In this comprehensive tutorial, I&#8217;ll walk you through everything you need to know to start building amazing web applications with Codeigniter 4, the latest version as of now. No confusing jargon, just straightforward guidance that&#8217;ll have you coding like a pro in no time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Makes Codeigniter So Special?<\/h2>\n\n\n\n<p>Before we dive into the code, let me tell you why Codeigniter stands out from other PHP frameworks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Lightning Fast<\/strong>: Codeigniter is incredibly lightweight and performs much faster than most other frameworks.<\/li>\n\n\n\n<li><strong>Easy Learning Curve<\/strong>: The documentation is superb, and the framework follows logical patterns that are easy to grasp.<\/li>\n\n\n\n<li><strong>Zero Configuration<\/strong>: You can set up and start developing with minimal configuration.<\/li>\n\n\n\n<li><strong>Built-in Security<\/strong>: The framework comes with powerful tools to protect your applications from common web attacks.<\/li>\n\n\n\n<li><strong>Community Support<\/strong>: A massive community means you&#8217;ll never get stuck on a problem for long.<\/li>\n<\/ul>\n\n\n\n<p>Trust me, once you start using Codeigniter, you&#8217;ll wonder how you ever developed without it!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before we begin, make sure you have:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Basic knowledge of PHP (you should understand variables, functions, and object-oriented concepts. Explore our <a href=\"https:\/\/codesamplez.com\/php-tutorials-and-examples\" target=\"_blank\" rel=\"noreferrer noopener\">PHP Tutorials<\/a> to level up your skill!)<\/li>\n\n\n\n<li>Understanding of the MVC design pattern (I&#8217;ll explain this more as we go)<\/li>\n\n\n\n<li>A local development environment (XAMPP, WAMP, or similar)<\/li>\n\n\n\n<li>PHP 8.1 or higher installed<\/li>\n\n\n\n<li>Composer installed (the PHP dependency manager)<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding MVC Architecture<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"800\" src=\"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/mvc-architecture-1200x800.webp\" alt=\"MVC(Model View Controller) Web Application Architecture Pattern Diagram\" class=\"wp-image-58778\" srcset=\"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/mvc-architecture-1200x800.webp 1200w, https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/mvc-architecture-300x200.webp 300w, https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/mvc-architecture-768x512.webp 768w, https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/mvc-architecture.webp 1536w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>Codeigniter uses the Model-View-Controller (MVC) pattern, which separates your application into three interconnected components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Models<\/strong>: Handle your data and business logic<\/li>\n\n\n\n<li><strong>Views<\/strong>: Display information to users<\/li>\n\n\n\n<li><strong>Controllers<\/strong>: Process user requests and coordinate between models and views<\/li>\n<\/ul>\n\n\n\n<p>This separation makes your code more organized, easier to maintain, and simpler to test. You&#8217;ll absolutely love how clean your codebase becomes!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Codeigniter 4<\/h2>\n\n\n\n<p>Let&#8217;s get started by installing Codeigniter 4. There are two ways to do this:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Method 1: Using Composer (Recommended)<\/h3>\n\n\n\n<p>Open your terminal or command prompt and run:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">composer create-project codeigniter4\/appstarter my-project<\/code><\/span><\/pre>\n\n\n<p>This creates a new Codeigniter project named &#8220;my-project&#8221; in the current directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Method 2: Manual Download<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download the latest version from <a href=\"https:\/\/codeigniter.com\/download\">Codeigniter&#8217;s official website<\/a><\/li>\n\n\n\n<li>Extract the files to your web server&#8217;s root directory<\/li>\n\n\n\n<li>Rename the directory to your project name<\/li>\n<\/ol>\n\n\n\n<p>I strongly recommend using the Composer method as it makes updating Codeigniter much easier in the future.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Directory Structure<\/h2>\n\n\n\n<p>After installation, you&#8217;ll see the following directory structure:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">my-project\/\n\u251c\u2500\u2500 app\/\n\u2502   \u251c\u2500\u2500 Config\/\n\u2502   \u251c\u2500\u2500 Controllers\/\n\u2502   \u251c\u2500\u2500 Models\/\n\u2502   \u251c\u2500\u2500 Views\/\n\u2502   \u2514\u2500\u2500 ...\n\u251c\u2500\u2500 <span class=\"hljs-keyword\">public<\/span>\/\n\u251c\u2500\u2500 system\/\n\u251c\u2500\u2500 writable\/\n\u251c\u2500\u2500 tests\/\n\u2514\u2500\u2500 vendor\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Let&#8217;s understand what each important directory does:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>app<\/strong>: This is where all YOUR code goes &#8211; controllers, models, views, config files, etc.<\/li>\n\n\n\n<li><strong>public<\/strong>: The only directory that should be publicly accessible. Contains index.php and assets like CSS, JS, and images.<\/li>\n\n\n\n<li><strong>system<\/strong>: Core framework files &#8211; NEVER modify these files directly!<\/li>\n\n\n\n<li><strong>writable<\/strong>: Contains files that need write access (logs, cache, etc.)<\/li>\n\n\n\n<li><strong>vendor<\/strong>: Contains third-party dependencies<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Configuration<\/h2>\n\n\n\n<p>Before we start building, let&#8217;s configure a few basics:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Environment Setup<\/h3>\n\n\n\n<p>Rename the <code>env<\/code> file to <code>.env<\/code> in your project root. Open it and set:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">CI_ENVIRONMENT = development<\/code><\/span><\/pre>\n\n\n<p>This enables detailed error reporting during development.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Database Configuration<\/h3>\n\n\n\n<p>In the <code>.env<\/code> file, configure your database settings:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">database.<span class=\"hljs-keyword\">default<\/span>.hostname = localhost\ndatabase.<span class=\"hljs-keyword\">default<\/span>.database = my_database\ndatabase.<span class=\"hljs-keyword\">default<\/span>.username = root\ndatabase.<span class=\"hljs-keyword\">default<\/span>.password = your_password\ndatabase.<span class=\"hljs-keyword\">default<\/span>.DBDriver = MySQLi<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">3. URL Configuration<\/h3>\n\n\n\n<p>Still in the <code>.env<\/code> file, set your base URL:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">app.baseURL = <span class=\"hljs-string\">'http:\/\/localhost\/my-project\/public\/'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Creating Your First Controller<\/h2>\n\n\n\n<p>Controllers are the heart of your application, handling user requests and providing responses. Let&#8217;s create our first controller:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a file named <code>Blog.php<\/code> in the <code>app\/Controllers<\/code> directory:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Controllers<\/span>;\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Blog<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">BaseController<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">index<\/span><span class=\"hljs-params\">()<\/span>\n    <\/span>{\n        <span class=\"hljs-keyword\">echo<\/span> <span class=\"hljs-string\">\"Hello World! Welcome to my blog.\"<\/span>;\n    }\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now, start your local server and navigate to <code>http:\/\/localhost\/my-project\/public\/blog<\/code>. You should see &#8220;Hello World! Welcome to my blog.&#8221; This simple controller demonstrates how easy it is to create pages in Codeigniter! \ud83c\udf89<\/p>\n\n\n\n<p><em>Tip\ud83d\udca1: Explore All <a href=\"https:\/\/codesamplez.com\/codeigniter-tutorials\" target=\"_blank\" rel=\"noreferrer noopener\">CodeIgniter Tutorials<\/a> by CodeSamplez.com<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Working with Views<\/h2>\n\n\n\n<p>Displaying raw text isn&#8217;t very useful. Let&#8217;s create a view to render HTML properly:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a directory <code>app\/Views\/blog<\/code><\/li>\n\n\n\n<li>Create a file <code>index.php<\/code> in this directory:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-meta-keyword\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>My Awesome Blog<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\n        <span class=\"hljs-selector-tag\">body<\/span> {\n            <span class=\"hljs-attribute\">font-family<\/span>: Arial, sans-serif;\n            <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-number\">1.6<\/span>;\n            <span class=\"hljs-attribute\">max-width<\/span>: <span class=\"hljs-number\">800px<\/span>;\n            <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span> auto;\n            <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">20px<\/span>;\n        }\n        <span class=\"hljs-selector-tag\">h1<\/span> {\n            <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#333<\/span>;\n            <span class=\"hljs-attribute\">border-bottom<\/span>: <span class=\"hljs-number\">1px<\/span> solid <span class=\"hljs-number\">#eee<\/span>;\n            <span class=\"hljs-attribute\">padding-bottom<\/span>: <span class=\"hljs-number\">10px<\/span>;\n        }\n        <span class=\"hljs-selector-class\">.article<\/span> {\n            <span class=\"hljs-attribute\">margin-bottom<\/span>: <span class=\"hljs-number\">30px<\/span>;\n            <span class=\"hljs-attribute\">border-bottom<\/span>: <span class=\"hljs-number\">1px<\/span> dashed <span class=\"hljs-number\">#ccc<\/span>;\n            <span class=\"hljs-attribute\">padding-bottom<\/span>: <span class=\"hljs-number\">20px<\/span>;\n        }\n        <span class=\"hljs-selector-class\">.article<\/span> <span class=\"hljs-selector-tag\">h2<\/span> {\n            <span class=\"hljs-attribute\">margin-bottom<\/span>: <span class=\"hljs-number\">5px<\/span>;\n        }\n        <span class=\"hljs-selector-class\">.meta<\/span> {\n            <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#777<\/span>;\n            <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">0.9em<\/span>;\n            <span class=\"hljs-attribute\">margin-bottom<\/span>: <span class=\"hljs-number\">15px<\/span>;\n        }\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Welcome to My Blog<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n    \n    <span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span> <span class=\"hljs-keyword\">foreach<\/span>($articles <span class=\"hljs-keyword\">as<\/span> $article): <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"article\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span><span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= $article-&gt;title <span class=\"hljs-meta\">?&gt;<\/span><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"meta\"<\/span>&gt;<\/span>By <span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= $article-&gt;author <span class=\"hljs-meta\">?&gt;<\/span><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span><span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= $article-&gt;content <span class=\"hljs-meta\">?&gt;<\/span><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    <span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span> <span class=\"hljs-keyword\">endforeach<\/span>; <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Now, update your controller to use this view:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Controllers<\/span>;\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Blog<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">BaseController<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">index<\/span><span class=\"hljs-params\">()<\/span>\n    <\/span>{\n        <span class=\"hljs-comment\">\/\/ Data to be passed to the view<\/span>\n        $data = &#91;\n            <span class=\"hljs-string\">'articles'<\/span> =&gt; &#91;\n                (object)&#91;\n                    <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-string\">'Getting Started with Codeigniter 4'<\/span>,\n                    <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-string\">'John Doe'<\/span>,\n                    <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-string\">'Codeigniter 4 is an amazing framework that makes PHP development a breeze.'<\/span>\n                ],\n                (object)&#91;\n                    <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-string\">'MVC Pattern Explained'<\/span>,\n                    <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-string\">'Jane Smith'<\/span>,\n                    <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-string\">'The Model-View-Controller pattern separates concerns and makes your code more maintainable.'<\/span>\n                ]\n            ]\n        ];\n        \n        <span class=\"hljs-comment\">\/\/ Load the view with data<\/span>\n        <span class=\"hljs-keyword\">return<\/span> view(<span class=\"hljs-string\">'blog\/index'<\/span>, $data);\n    }\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>When you refresh the page, you&#8217;ll see a nicely formatted blog with two articles. That&#8217;s the power of views &#8211; they separate your HTML from your PHP logic!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a Model<\/h2>\n\n\n\n<p>Models handle your data operations. Let&#8217;s create a model to manage our blog articles:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a file named <code>BlogModel.php<\/code> in the <code>app\/Models<\/code> directory:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Models<\/span>;\n\n<span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">CodeIgniter<\/span>\\<span class=\"hljs-title\">Model<\/span>;\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">BlogModel<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">Model<\/span>\n<\/span>{\n    <span class=\"hljs-comment\">\/\/ In a real application, you'd connect to a database<\/span>\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">getArticles<\/span><span class=\"hljs-params\">()<\/span>\n    <\/span>{\n        <span class=\"hljs-comment\">\/\/ For now, we'll return dummy data<\/span>\n        <span class=\"hljs-keyword\">return<\/span> &#91;\n            (object)&#91;\n                <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-string\">'Getting Started with Codeigniter 4'<\/span>,\n                <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-string\">'John Doe'<\/span>,\n                <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-string\">'Codeigniter 4 is an amazing framework that makes PHP development a breeze.'<\/span>\n            ],\n            (object)&#91;\n                <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-string\">'MVC Pattern Explained'<\/span>,\n                <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-string\">'Jane Smith'<\/span>,\n                <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-string\">'The Model-View-Controller pattern separates concerns and makes your code more maintainable.'<\/span>\n            ],\n            (object)&#91;\n                <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-string\">'Working with Databases in CI4'<\/span>,\n                <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-string\">'Mike Johnson'<\/span>,\n                <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-string\">'Codeigniter makes database operations simple with its powerful database library.'<\/span>\n            ]\n        ];\n    }\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Update your controller to use this model:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Controllers<\/span>;\n\n<span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Models<\/span>\\<span class=\"hljs-title\">BlogModel<\/span>;\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Blog<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">BaseController<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">index<\/span><span class=\"hljs-params\">()<\/span>\n    <\/span>{\n        <span class=\"hljs-comment\">\/\/ Create an instance of the model<\/span>\n        $model = <span class=\"hljs-keyword\">new<\/span> BlogModel();\n        \n        <span class=\"hljs-comment\">\/\/ Get data from the model<\/span>\n        $data = &#91;\n            <span class=\"hljs-string\">'articles'<\/span> =&gt; $model-&gt;getArticles()\n        ];\n        \n        <span class=\"hljs-comment\">\/\/ Load the view with data<\/span>\n        <span class=\"hljs-keyword\">return<\/span> view(<span class=\"hljs-string\">'blog\/index'<\/span>, $data);\n    }\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Working with a Real Database<\/h2>\n\n\n\n<p>Now let&#8217;s upgrade our model to use a real database:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a database table:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">CREATE TABLE articles (\n    id INT(<span class=\"hljs-number\">11<\/span>) PRIMARY KEY AUTO_INCREMENT,\n    title VARCHAR(<span class=\"hljs-number\">255<\/span>) NOT <span class=\"hljs-keyword\">NULL<\/span>,\n    author VARCHAR(<span class=\"hljs-number\">100<\/span>) NOT <span class=\"hljs-keyword\">NULL<\/span>,\n    content TEXT NOT <span class=\"hljs-keyword\">NULL<\/span>,\n    created_at DATETIME <span class=\"hljs-keyword\">DEFAULT<\/span> CURRENT_TIMESTAMP\n);\n\nINSERT INTO articles (title, author, content) VALUES\n(<span class=\"hljs-string\">'Getting Started with Codeigniter 4'<\/span>, <span class=\"hljs-string\">'John Doe'<\/span>, <span class=\"hljs-string\">'Codeigniter 4 is an amazing framework that makes PHP development a breeze.'<\/span>),\n(<span class=\"hljs-string\">'MVC Pattern Explained'<\/span>, <span class=\"hljs-string\">'Jane Smith'<\/span>, <span class=\"hljs-string\">'The Model-View-Controller pattern separates concerns and makes your code more maintainable.'<\/span>),\n(<span class=\"hljs-string\">'Working with Databases in CI4'<\/span>, <span class=\"hljs-string\">'Mike Johnson'<\/span>, <span class=\"hljs-string\">'Codeigniter makes database operations simple with its powerful database library.'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Update your model to use the database:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Models<\/span>;\n\n<span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">CodeIgniter<\/span>\\<span class=\"hljs-title\">Model<\/span>;\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">BlogModel<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">Model<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">protected<\/span> $table = <span class=\"hljs-string\">'articles'<\/span>;\n    <span class=\"hljs-keyword\">protected<\/span> $primaryKey = <span class=\"hljs-string\">'id'<\/span>;\n    <span class=\"hljs-keyword\">protected<\/span> $allowedFields = &#91;<span class=\"hljs-string\">'title'<\/span>, <span class=\"hljs-string\">'author'<\/span>, <span class=\"hljs-string\">'content'<\/span>];\n    <span class=\"hljs-keyword\">protected<\/span> $useTimestamps = <span class=\"hljs-keyword\">true<\/span>;\n    <span class=\"hljs-keyword\">protected<\/span> $createdField = <span class=\"hljs-string\">'created_at'<\/span>;\n    <span class=\"hljs-keyword\">protected<\/span> $updatedField = <span class=\"hljs-string\">'updated_at'<\/span>;\n    \n    <span class=\"hljs-comment\">\/\/ No need for a custom getArticles method - we can use the built-in findAll()<\/span>\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Update your controller:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span>\n\n<span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Controllers<\/span>;\n\n<span class=\"hljs-keyword\">use<\/span> <span class=\"hljs-title\">App<\/span>\\<span class=\"hljs-title\">Models<\/span>\\<span class=\"hljs-title\">BlogModel<\/span>;\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Blog<\/span> <span class=\"hljs-keyword\">extends<\/span> <span class=\"hljs-title\">BaseController<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">index<\/span><span class=\"hljs-params\">()<\/span>\n    <\/span>{\n        $model = <span class=\"hljs-keyword\">new<\/span> BlogModel();\n        \n        $data = &#91;\n            <span class=\"hljs-string\">'articles'<\/span> =&gt; $model-&gt;findAll()\n        ];\n        \n        <span class=\"hljs-keyword\">return<\/span> view(<span class=\"hljs-string\">'blog\/index'<\/span>, $data);\n    }\n}<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>That&#8217;s it! Codeigniter&#8217;s model system makes database operations incredibly simple. You get all the CRUD (Create, Read, Update, Delete) operations without writing a single SQL query!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating Forms and Handling Input<\/h2>\n\n\n\n<p>Let&#8217;s add functionality to create new blog posts:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new view <code>app\/Views\/blog\/create.php<\/code>:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-meta-keyword\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>Create New Article<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\n        <span class=\"hljs-selector-tag\">body<\/span> {\n            <span class=\"hljs-attribute\">font-family<\/span>: Arial, sans-serif;\n            <span class=\"hljs-attribute\">line-height<\/span>: <span class=\"hljs-number\">1.6<\/span>;\n            <span class=\"hljs-attribute\">max-width<\/span>: <span class=\"hljs-number\">800px<\/span>;\n            <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span> auto;\n            <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">20px<\/span>;\n        }\n        <span class=\"hljs-selector-tag\">h1<\/span> {\n            <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#333<\/span>;\n            <span class=\"hljs-attribute\">border-bottom<\/span>: <span class=\"hljs-number\">1px<\/span> solid <span class=\"hljs-number\">#eee<\/span>;\n            <span class=\"hljs-attribute\">padding-bottom<\/span>: <span class=\"hljs-number\">10px<\/span>;\n        }\n        <span class=\"hljs-selector-class\">.form-group<\/span> {\n            <span class=\"hljs-attribute\">margin-bottom<\/span>: <span class=\"hljs-number\">15px<\/span>;\n        }\n        <span class=\"hljs-selector-tag\">label<\/span> {\n            <span class=\"hljs-attribute\">display<\/span>: block;\n            <span class=\"hljs-attribute\">margin-bottom<\/span>: <span class=\"hljs-number\">5px<\/span>;\n        }\n        <span class=\"hljs-selector-tag\">input<\/span><span class=\"hljs-selector-attr\">&#91;type=<span class=\"hljs-string\">\"text\"<\/span>]<\/span>, <span class=\"hljs-selector-tag\">textarea<\/span> {\n            <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">100%<\/span>;\n            <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">8px<\/span>;\n            <span class=\"hljs-attribute\">border<\/span>: <span class=\"hljs-number\">1px<\/span> solid <span class=\"hljs-number\">#ddd<\/span>;\n        }\n        <span class=\"hljs-selector-tag\">textarea<\/span> {\n            <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">150px<\/span>;\n        }\n        <span class=\"hljs-selector-tag\">button<\/span> {\n            <span class=\"hljs-attribute\">background<\/span>: <span class=\"hljs-number\">#4CAF50<\/span>;\n            <span class=\"hljs-attribute\">color<\/span>: white;\n            <span class=\"hljs-attribute\">border<\/span>: none;\n            <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">10px<\/span> <span class=\"hljs-number\">15px<\/span>;\n            <span class=\"hljs-attribute\">cursor<\/span>: pointer;\n        }\n    <\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Create New Article<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n    \n    <span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span> <span class=\"hljs-keyword\">if<\/span>(session()-&gt;getFlashdata(<span class=\"hljs-string\">'error'<\/span>)): <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">style<\/span>=<span class=\"hljs-string\">\"color: red; margin-bottom: 15px;\"<\/span>&gt;<\/span>\n            <span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= session()-&gt;getFlashdata(<span class=\"hljs-string\">'error'<\/span>) <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    <span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span> <span class=\"hljs-keyword\">endif<\/span>; <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n    \n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">form<\/span> <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\">\"&lt;?= site_url('blog\/store') ?&gt;\"<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\">\"post\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"form-group\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span> <span class=\"hljs-attr\">for<\/span>=<span class=\"hljs-string\">\"title\"<\/span>&gt;<\/span>Title<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"text\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"title\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"title\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n        \n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"form-group\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span> <span class=\"hljs-attr\">for<\/span>=<span class=\"hljs-string\">\"author\"<\/span>&gt;<\/span>Author<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"text\"<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"author\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"author\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n        \n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"form-group\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span> <span class=\"hljs-attr\">for<\/span>=<span class=\"hljs-string\">\"content\"<\/span>&gt;<\/span>Content<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">textarea<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"content\"<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"content\"<\/span> <span class=\"hljs-attr\">required<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">textarea<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n        \n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"submit\"<\/span>&gt;<\/span>Create Article<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">form<\/span>&gt;<\/span>\n    \n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"&lt;?= site_url('blog') ?&gt;\"<\/span>&gt;<\/span>Back to Articles<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Add methods to your controller:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\">\/\/ In Blog.php controller<\/span>\n\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">create<\/span><span class=\"hljs-params\">()<\/span>\n<\/span>{\n    <span class=\"hljs-keyword\">return<\/span> view(<span class=\"hljs-string\">'blog\/create'<\/span>);\n}\n\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">store<\/span><span class=\"hljs-params\">()<\/span>\n<\/span>{\n    <span class=\"hljs-comment\">\/\/ Validate input<\/span>\n    $rules = &#91;\n        <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-string\">'required|min_length&#91;3]|max_length&#91;255]'<\/span>,\n        <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-string\">'required|min_length&#91;3]|max_length&#91;100]'<\/span>,\n        <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-string\">'required|min_length&#91;10]'<\/span>\n    ];\n    \n    <span class=\"hljs-keyword\">if<\/span> (!<span class=\"hljs-keyword\">$this<\/span>-&gt;validate($rules)) {\n        <span class=\"hljs-keyword\">return<\/span> redirect()-&gt;back()-&gt;withInput()-&gt;with(<span class=\"hljs-string\">'error'<\/span>, <span class=\"hljs-keyword\">$this<\/span>-&gt;validator-&gt;getErrors());\n    }\n    \n    <span class=\"hljs-comment\">\/\/ Get form data<\/span>\n    $data = &#91;\n        <span class=\"hljs-string\">'title'<\/span> =&gt; <span class=\"hljs-keyword\">$this<\/span>-&gt;request-&gt;getPost(<span class=\"hljs-string\">'title'<\/span>),\n        <span class=\"hljs-string\">'author'<\/span> =&gt; <span class=\"hljs-keyword\">$this<\/span>-&gt;request-&gt;getPost(<span class=\"hljs-string\">'author'<\/span>),\n        <span class=\"hljs-string\">'content'<\/span> =&gt; <span class=\"hljs-keyword\">$this<\/span>-&gt;request-&gt;getPost(<span class=\"hljs-string\">'content'<\/span>)\n    ];\n    \n    <span class=\"hljs-comment\">\/\/ Save to database<\/span>\n    $model = <span class=\"hljs-keyword\">new<\/span> BlogModel();\n    $model-&gt;insert($data);\n    \n    <span class=\"hljs-comment\">\/\/ Redirect to blog list<\/span>\n    <span class=\"hljs-keyword\">return<\/span> redirect()-&gt;to(<span class=\"hljs-string\">'\/blog'<\/span>)-&gt;with(<span class=\"hljs-string\">'message'<\/span>, <span class=\"hljs-string\">'Article created successfully!'<\/span>);\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Add a link to the create page in your index view:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- Add this near the top of app\/Views\/blog\/index.php --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"&lt;?= site_url('blog\/create') ?&gt;\"<\/span>&gt;<\/span>Create New Article<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n\n<span class=\"hljs-comment\">&lt;!-- And add this to display success message --&gt;<\/span>\n<span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span> <span class=\"hljs-keyword\">if<\/span>(session()-&gt;getFlashdata(<span class=\"hljs-string\">'message'<\/span>)): <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">style<\/span>=<span class=\"hljs-string\">\"background: #d4edda; color: #155724; padding: 10px; margin-bottom: 20px;\"<\/span>&gt;<\/span>\n        <span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= session()-&gt;getFlashdata(<span class=\"hljs-string\">'message'<\/span>) <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n<span class=\"php\"><span class=\"hljs-meta\">&lt;?php<\/span> <span class=\"hljs-keyword\">endif<\/span>; <span class=\"hljs-meta\">?&gt;<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Routes<\/h2>\n\n\n\n<p>Codeigniter 4 offers powerful routing capabilities. Let&#8217;s configure some routes to make our URLs cleaner:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <code>app\/Config\/Routes.php<\/code> and add:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$routes-&gt;get(<span class=\"hljs-string\">'blog'<\/span>, <span class=\"hljs-string\">'Blog::index'<\/span>);\n$routes-&gt;get(<span class=\"hljs-string\">'blog\/create'<\/span>, <span class=\"hljs-string\">'Blog::create'<\/span>);\n$routes-&gt;post(<span class=\"hljs-string\">'blog\/store'<\/span>, <span class=\"hljs-string\">'Blog::store'<\/span>);\n$routes-&gt;get(<span class=\"hljs-string\">'blog\/(:num)'<\/span>, <span class=\"hljs-string\">'Blog::show\/$1'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This allows URLs like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>http:\/\/localhost\/my-project\/public\/blog<\/code> for the index<\/li>\n\n\n\n<li><code>http:\/\/localhost\/my-project\/public\/blog\/create<\/code> to create an article<\/li>\n\n\n\n<li><code>http:\/\/localhost\/my-project\/public\/blog\/1<\/code> to view article #1<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Handling AJAX Requests<\/h2>\n\n\n\n<p>Want to add some interactivity? Here&#8217;s how to handle AJAX requests in Codeigniter:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add a new method to your controller:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">like<\/span><span class=\"hljs-params\">($id)<\/span>\n<\/span>{\n    <span class=\"hljs-comment\">\/\/ In a real app, you'd update a likes count in the database<\/span>\n    \n    <span class=\"hljs-comment\">\/\/ For now, just return a response<\/span>\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-keyword\">$this<\/span>-&gt;response-&gt;setJSON(&#91;<span class=\"hljs-string\">'success'<\/span> =&gt; <span class=\"hljs-keyword\">true<\/span>, <span class=\"hljs-string\">'likes'<\/span> =&gt; rand(<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">100<\/span>)]);\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Add some JavaScript to your view:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- Add this to your index.php view, before the closing body tag --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"javascript\">\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">likeArticle<\/span>(<span class=\"hljs-params\">id<\/span>) <\/span>{\n    fetch(<span class=\"hljs-string\">`&lt;?= site_url('blog\/like') ?&gt;\/<span class=\"hljs-subst\">${id}<\/span>`<\/span>)\n        .then(<span class=\"hljs-function\"><span class=\"hljs-params\">response<\/span> =&gt;<\/span> response.json())\n        .then(<span class=\"hljs-function\"><span class=\"hljs-params\">data<\/span> =&gt;<\/span> {\n            <span class=\"hljs-keyword\">if<\/span> (data.success) {\n                <span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">`likes-<span class=\"hljs-subst\">${id}<\/span>`<\/span>).textContent = data.likes;\n            }\n        });\n}\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\n\n<span class=\"hljs-comment\">&lt;!-- And modify your article display to add a like button --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"article\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span><span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= $article-&gt;title <span class=\"hljs-meta\">?&gt;<\/span><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"meta\"<\/span>&gt;<\/span>\n        By <span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= $article-&gt;author <span class=\"hljs-meta\">?&gt;<\/span><\/span> | \n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">span<\/span> <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"likes-&lt;?= $article-&gt;id ?&gt;\"<\/span>&gt;<\/span>0<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">span<\/span>&gt;<\/span> likes\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">onclick<\/span>=<span class=\"hljs-string\">\"likeArticle(&lt;?= $article-&gt;id ?&gt;)\"<\/span>&gt;<\/span>Like<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span><span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= $article-&gt;content <span class=\"hljs-meta\">?&gt;<\/span><\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Using Helper Functions<\/h2>\n\n\n\n<p>Codeigniter comes with many helper functions to simplify common tasks. Let&#8217;s use some:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Load helpers in your controller:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-comment\">\/\/ In Blog.php controller constructor or method<\/span>\nhelper(&#91;<span class=\"hljs-string\">'form'<\/span>, <span class=\"hljs-string\">'url'<\/span>]);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Now you can use helper functions in your views:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- Instead of --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">form<\/span> <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\">\"&lt;?= site_url('blog\/store') ?&gt;\"<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\">\"post\"<\/span>&gt;<\/span>\n\n<span class=\"hljs-comment\">&lt;!-- You can write --&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">form<\/span> <span class=\"hljs-attr\">action<\/span>=<span class=\"hljs-string\">\"&lt;?= site_url('blog\/store') ?&gt;\"<\/span> <span class=\"hljs-attr\">method<\/span>=<span class=\"hljs-string\">\"post\"<\/span>&gt;<\/span>\n    <span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= csrf_field() <span class=\"hljs-meta\">?&gt;<\/span><\/span> <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">em<\/span>&gt;<\/span><span class=\"hljs-comment\">&lt;!-- Adds CSRF protection token --&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">em<\/span>&gt;<\/span>\n    \n    <span class=\"hljs-comment\">&lt;!-- Form inputs here --&gt;<\/span>\n    <span class=\"php\"><span class=\"hljs-meta\">&lt;?<\/span>= form_submit(<span class=\"hljs-string\">'submit'<\/span>, <span class=\"hljs-string\">'Create Article'<\/span>, &#91;<span class=\"hljs-string\">'class'<\/span> =&gt; <span class=\"hljs-string\">'button'<\/span>]) <span class=\"hljs-meta\">?&gt;<\/span><\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">form<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Adding Authentication<\/h2>\n\n\n\n<p>Most web applications need authentication. Let&#8217;s implement basic login\/registration:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install the Shield authentication module (Codeigniter&#8217;s official auth solution):<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">composer <span class=\"hljs-built_in\">require<\/span> codeigniter4\/shield<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Run the migrations:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">php<\/span> <span class=\"hljs-selector-tag\">spark<\/span> <span class=\"hljs-selector-tag\">shield<\/span><span class=\"hljs-selector-pseudo\">:setup<\/span>\n<span class=\"hljs-selector-tag\">php<\/span> <span class=\"hljs-selector-tag\">spark<\/span> <span class=\"hljs-selector-tag\">migrate<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Create a route group with authentication:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\">\/\/ In app\/Config\/Routes.php<\/span>\n$routes-&gt;group(<span class=\"hljs-string\">'admin'<\/span>, &#91;<span class=\"hljs-string\">'filter'<\/span> =&gt; <span class=\"hljs-string\">'auth'<\/span>], <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span><span class=\"hljs-params\">($routes)<\/span> <\/span>{\n    $routes-&gt;get(<span class=\"hljs-string\">'dashboard'<\/span>, <span class=\"hljs-string\">'Admin::dashboard'<\/span>);\n    <span class=\"hljs-comment\">\/\/ Other protected routes here<\/span>\n});<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This ensures only authenticated users can access the admin section!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tips for Debugging<\/h2>\n\n\n\n<p>Codeigniter offers excellent tools for debugging your application:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Enable debug toolbar by setting:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">CI_ENVIRONMENT = development<\/code><\/span><\/pre>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Use the debug bar to inspect:\n<ul class=\"wp-block-list\">\n<li>Request and response data<\/li>\n\n\n\n<li>Database queries<\/li>\n\n\n\n<li>Performance metrics<\/li>\n\n\n\n<li>Loaded files<\/li>\n\n\n\n<li>And much more!<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>For logging custom messages:<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">log_message(<span class=\"hljs-string\">'debug'<\/span>, <span class=\"hljs-string\">'This is a debug message'<\/span>);\nlog_message(<span class=\"hljs-string\">'error'<\/span>, <span class=\"hljs-string\">'Something went wrong!'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Common Pitfalls to Avoid<\/h2>\n\n\n\n<p>As you develop with Codeigniter, watch out for these common mistakes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Forgetting namespaces<\/strong>: Always include the correct namespace for your models and controllers.<\/li>\n\n\n\n<li><strong>Direct model property access<\/strong>: Use getter and setter methods instead of direct property access: <\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-24\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\">\/\/ Incorrect <\/span>\n$article-&gt;title = <span class=\"hljs-string\">'New Title'<\/span>; \n<span class=\"hljs-comment\">\/\/ Correct <\/span>\n$article-&gt;setTitle(<span class=\"hljs-string\">'New Title'<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-24\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Not escaping output<\/strong>: Always use the <code>esc()<\/code> function to prevent XSS attacks: php<code>&lt;?= esc($article-&gt;title) ?&gt;<\/code><\/li>\n\n\n\n<li><strong>Ignoring validation<\/strong>: Always validate user input before processing it.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Codeigniter Development<\/h2>\n\n\n\n<p>To get the most out of Codeigniter, follow these best practices:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Use environment files<\/strong>: Keep sensitive data (like API keys) in <code>.env<\/code> files.<\/li>\n\n\n\n<li><strong>Create Base Controllers<\/strong>: Extend BaseController for common functionality across controllers.<\/li>\n\n\n\n<li><strong>Use Services<\/strong>: Leverage Codeigniter&#8217;s service system for dependency injection.<\/li>\n\n\n\n<li><strong>Organize Business Logic<\/strong>: Keep heavy logic in models or services, not controllers.<\/li>\n\n\n\n<li><strong>Use Migrations<\/strong>: Use database migrations for version control of your database structure.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Congratulations! You&#8217;ve now mastered the basics of Codeigniter development. This incredibly powerful framework makes PHP development faster, more secure, and much more enjoyable. From creating simple blogs to complex applications, Codeigniter has absolutely everything you need.<\/p>\n\n\n\n<p>Remember, the best way to learn is by doing. Take what you&#8217;ve learned in this tutorial and start building your own projects. The more you practice, the more comfortable you&#8217;ll become with the framework.<\/p>\n\n\n\n<p>And don&#8217;t forget &#8211; the <a href=\"https:\/\/codeigniter.com\/user_guide\/\" target=\"_blank\" rel=\"noreferrer noopener\">official Codeigniter documentation<\/a> is your best friend. It&#8217;s comprehensive, well-written, and updated regularly.<\/p>\n\n\n\n<p>Happy coding with Codeigniter! If you found this tutorial helpful, please share it with others who might benefit from it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This beginner-friendly tutorial from CodeSamplez guides you through building a simple CodeIgniter application using the MVC (Model-View-Controller) framework. It covers setting up the development environment, creating controllers, views, and models, and integrating database operations. Ideal for newcomers, it offers a practical approach to learning PHP web development with CodeIgniter.<\/p>\n","protected":false},"author":1,"featured_media":58777,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11],"tags":[21,3],"class_list":{"0":"post-730","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-development","8":"tag-codeigniter","9":"tag-php","10":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Codeigniter Tutorial For Beginners: PHP Web Application Guide - CodeSamplez.com<\/title>\n<meta name=\"description\" content=\"Learn to build powerful web applications with this comprehensive Codeigniter tutorial for beginners. Master MVC architecture, database an more\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Codeigniter Tutorial For Beginners: PHP Web Application Guide\" \/>\n<meta property=\"og:description\" content=\"Learn to build powerful web applications with this comprehensive Codeigniter tutorial for beginners. Master MVC architecture, database an more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial\" \/>\n<meta property=\"og:site_name\" content=\"CodeSamplez.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codesamplez\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ranacseruet\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-02T07:13:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-24T16:14:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Rana Ahsan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ranacseruet\" \/>\n<meta name=\"twitter:site\" content=\"@codesamplez\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rana Ahsan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial\"},\"author\":{\"name\":\"Rana Ahsan\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#\\\/schema\\\/person\\\/a82c3c07205f4bb73d6b3b0906bc328b\"},\"headline\":\"Codeigniter Tutorial For Beginners: PHP Web Application Guide\",\"datePublished\":\"2011-05-02T07:13:02+00:00\",\"dateModified\":\"2025-05-24T16:14:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial\"},\"wordCount\":1246,\"commentCount\":49,\"publisher\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codesamplez.com\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/codeigniter-tutorial-for-beginners.webp\",\"keywords\":[\"codeigniter\",\"php\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial\",\"url\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial\",\"name\":\"Codeigniter Tutorial For Beginners: PHP Web Application Guide - CodeSamplez.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codesamplez.com\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/codeigniter-tutorial-for-beginners.webp\",\"datePublished\":\"2011-05-02T07:13:02+00:00\",\"dateModified\":\"2025-05-24T16:14:39+00:00\",\"description\":\"Learn to build powerful web applications with this comprehensive Codeigniter tutorial for beginners. Master MVC architecture, database an more\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#primaryimage\",\"url\":\"https:\\\/\\\/codesamplez.com\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/codeigniter-tutorial-for-beginners.webp\",\"contentUrl\":\"https:\\\/\\\/codesamplez.com\\\/wp-content\\\/uploads\\\/2011\\\/05\\\/codeigniter-tutorial-for-beginners.webp\",\"width\":1536,\"height\":1024,\"caption\":\"codeigniter tutorial for beginners\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/development\\\/codeigniter-basic-tutorial#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codesamplez.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Codeigniter Tutorial For Beginners: PHP Web Application Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#website\",\"url\":\"https:\\\/\\\/codesamplez.com\\\/\",\"name\":\"CODESAMPLEZ.COM\",\"description\":\"Programming And Development Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codesamplez.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#organization\",\"name\":\"codesamplez.com\",\"url\":\"https:\\\/\\\/codesamplez.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codesamplez.com\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/cropped-favicon.webp\",\"contentUrl\":\"https:\\\/\\\/codesamplez.com\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/cropped-favicon.webp\",\"width\":512,\"height\":512,\"caption\":\"codesamplez.com\"},\"image\":{\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codesamplez\",\"https:\\\/\\\/x.com\\\/codesamplez\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codesamplez.com\\\/#\\\/schema\\\/person\\\/a82c3c07205f4bb73d6b3b0906bc328b\",\"name\":\"Rana Ahsan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c7a4f88bcf4a55cd1483386318ebecf27359154275a0b355b0ea186676f9f7f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c7a4f88bcf4a55cd1483386318ebecf27359154275a0b355b0ea186676f9f7f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c7a4f88bcf4a55cd1483386318ebecf27359154275a0b355b0ea186676f9f7f?s=96&d=mm&r=g\",\"caption\":\"Rana Ahsan\"},\"description\":\"Rana Ahsan is a seasoned software engineer and technology leader specialized in distributed systems and software architecture. With a Master\u2019s in Software Engineering from Concordia University, his experience spans leading scalable architecture at Coursera and TopHat, contributing to open-source projects. This blog, CodeSamplez.com, showcases his passion for sharing practical insights on programming and distributed systems concepts and help educate others. Github | X | LinkedIn\",\"sameAs\":[\"https:\\\/\\\/github.com\\\/ranacseruet\",\"https:\\\/\\\/www.facebook.com\\\/ranacseruet\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/ranacseruet\\\/\",\"https:\\\/\\\/x.com\\\/ranacseruet\"],\"url\":\"https:\\\/\\\/codesamplez.com\\\/author\\\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Codeigniter Tutorial For Beginners: PHP Web Application Guide - CodeSamplez.com","description":"Learn to build powerful web applications with this comprehensive Codeigniter tutorial for beginners. Master MVC architecture, database an more","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial","og_locale":"en_US","og_type":"article","og_title":"Codeigniter Tutorial For Beginners: PHP Web Application Guide","og_description":"Learn to build powerful web applications with this comprehensive Codeigniter tutorial for beginners. Master MVC architecture, database an more","og_url":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial","og_site_name":"CodeSamplez.com","article_publisher":"https:\/\/www.facebook.com\/codesamplez","article_author":"https:\/\/www.facebook.com\/ranacseruet","article_published_time":"2011-05-02T07:13:02+00:00","article_modified_time":"2025-05-24T16:14:39+00:00","og_image":[{"width":1536,"height":1024,"url":"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp","type":"image\/webp"}],"author":"Rana Ahsan","twitter_card":"summary_large_image","twitter_creator":"@ranacseruet","twitter_site":"@codesamplez","twitter_misc":{"Written by":"Rana Ahsan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#article","isPartOf":{"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial"},"author":{"name":"Rana Ahsan","@id":"https:\/\/codesamplez.com\/#\/schema\/person\/a82c3c07205f4bb73d6b3b0906bc328b"},"headline":"Codeigniter Tutorial For Beginners: PHP Web Application Guide","datePublished":"2011-05-02T07:13:02+00:00","dateModified":"2025-05-24T16:14:39+00:00","mainEntityOfPage":{"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial"},"wordCount":1246,"commentCount":49,"publisher":{"@id":"https:\/\/codesamplez.com\/#organization"},"image":{"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#primaryimage"},"thumbnailUrl":"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp","keywords":["codeigniter","php"],"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial","url":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial","name":"Codeigniter Tutorial For Beginners: PHP Web Application Guide - CodeSamplez.com","isPartOf":{"@id":"https:\/\/codesamplez.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#primaryimage"},"image":{"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#primaryimage"},"thumbnailUrl":"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp","datePublished":"2011-05-02T07:13:02+00:00","dateModified":"2025-05-24T16:14:39+00:00","description":"Learn to build powerful web applications with this comprehensive Codeigniter tutorial for beginners. Master MVC architecture, database an more","breadcrumb":{"@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#primaryimage","url":"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp","contentUrl":"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp","width":1536,"height":1024,"caption":"codeigniter tutorial for beginners"},{"@type":"BreadcrumbList","@id":"https:\/\/codesamplez.com\/development\/codeigniter-basic-tutorial#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codesamplez.com\/"},{"@type":"ListItem","position":2,"name":"Codeigniter Tutorial For Beginners: PHP Web Application Guide"}]},{"@type":"WebSite","@id":"https:\/\/codesamplez.com\/#website","url":"https:\/\/codesamplez.com\/","name":"CODESAMPLEZ.COM","description":"Programming And Development Resources","publisher":{"@id":"https:\/\/codesamplez.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codesamplez.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codesamplez.com\/#organization","name":"codesamplez.com","url":"https:\/\/codesamplez.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codesamplez.com\/#\/schema\/logo\/image\/","url":"https:\/\/codesamplez.com\/wp-content\/uploads\/2024\/10\/cropped-favicon.webp","contentUrl":"https:\/\/codesamplez.com\/wp-content\/uploads\/2024\/10\/cropped-favicon.webp","width":512,"height":512,"caption":"codesamplez.com"},"image":{"@id":"https:\/\/codesamplez.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codesamplez","https:\/\/x.com\/codesamplez"]},{"@type":"Person","@id":"https:\/\/codesamplez.com\/#\/schema\/person\/a82c3c07205f4bb73d6b3b0906bc328b","name":"Rana Ahsan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c7a4f88bcf4a55cd1483386318ebecf27359154275a0b355b0ea186676f9f7f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c7a4f88bcf4a55cd1483386318ebecf27359154275a0b355b0ea186676f9f7f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c7a4f88bcf4a55cd1483386318ebecf27359154275a0b355b0ea186676f9f7f?s=96&d=mm&r=g","caption":"Rana Ahsan"},"description":"Rana Ahsan is a seasoned software engineer and technology leader specialized in distributed systems and software architecture. With a Master\u2019s in Software Engineering from Concordia University, his experience spans leading scalable architecture at Coursera and TopHat, contributing to open-source projects. This blog, CodeSamplez.com, showcases his passion for sharing practical insights on programming and distributed systems concepts and help educate others. Github | X | LinkedIn","sameAs":["https:\/\/github.com\/ranacseruet","https:\/\/www.facebook.com\/ranacseruet","https:\/\/www.linkedin.com\/in\/ranacseruet\/","https:\/\/x.com\/ranacseruet"],"url":"https:\/\/codesamplez.com\/author\/admin"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/codesamplez.com\/wp-content\/uploads\/2011\/05\/codeigniter-tutorial-for-beginners.webp","jetpack_shortlink":"https:\/\/wp.me\/p1hHlI-bM","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":22372,"url":"https:\/\/codesamplez.com\/projects\/codeigniter-bundle","url_meta":{"origin":730,"position":0},"title":"CodeIgniterPlus, The Ultimate CodeIgniter Enhancement","author":"Rana Ahsan","date":"December 19, 2012","format":false,"excerpt":"Deprecation Warning: Outdated Content. This time, I am not going to share a tutorial with you. Instead, I would like to share a resource with you which may help you have a kick-ass beginning on the way of your web application development. So, today, there will be no code examples\u2026","rel":"","context":"In &quot;Projects&quot;","block_context":{"text":"Projects","link":"https:\/\/codesamplez.com\/category\/projects"},"img":{"alt_text":"CodeigniterPlus Home screenshot","src":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2012\/12\/CodeigniterPlus-screenshot.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2012\/12\/CodeigniterPlus-screenshot.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2012\/12\/CodeigniterPlus-screenshot.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2012\/12\/CodeigniterPlus-screenshot.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2012\/12\/CodeigniterPlus-screenshot.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":815,"url":"https:\/\/codesamplez.com\/development\/codeigniter-smarty","url_meta":{"origin":730,"position":1},"title":"Smarty With CodeIgniter: Create CodeIgniter Views Like A Pro","author":"Rana Ahsan","date":"June 7, 2011","format":false,"excerpt":"This tutorial provides a comprehensive guide to integrating the Smarty templating engine with the CodeIgniter framework. It covers the setup process, including directory structure and configuration, and demonstrates how to render views using Smarty within CodeIgniter. By combining Smarty's powerful templating features with CodeIgniter's MVC architecture, developers can create cleaner,\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/codesamplez.com\/category\/development"},"img":{"alt_text":"smarty with codeigniter","src":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/smarty-with-codeigniter.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/smarty-with-codeigniter.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/smarty-with-codeigniter.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/smarty-with-codeigniter.webp?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/smarty-with-codeigniter.webp?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/smarty-with-codeigniter.webp?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":829,"url":"https:\/\/codesamplez.com\/development\/using-doctrine-with-codeigniter","url_meta":{"origin":730,"position":2},"title":"Doctrine With CodeIgniter: DB Modeling In CodeIngiter Like A Pro","author":"Rana Ahsan","date":"June 15, 2011","format":false,"excerpt":"Learn how to integrate Doctrine ORM with CodeIgniter in this tutorial, which provides step-by-step guidance and PHP code examples. Discover how to set up Doctrine within the CodeIgniter framework and leverage its features for efficient database modeling and management. This guide is ideal for developers aiming to enhance their CodeIgniter\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/codesamplez.com\/category\/development"},"img":{"alt_text":"doctrine with codeigniter","src":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/doctrine-with-codeigniter.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/doctrine-with-codeigniter.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/doctrine-with-codeigniter.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/doctrine-with-codeigniter.webp?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/doctrine-with-codeigniter.webp?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/06\/doctrine-with-codeigniter.webp?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":22759,"url":"https:\/\/codesamplez.com\/development\/codeigniter-caching-tutorial-php","url_meta":{"origin":730,"position":3},"title":"CodeIgniter Caching Guide: 10X Your App Performance","author":"Rana Ahsan","date":"January 22, 2013","format":false,"excerpt":"This article offers a comprehensive guide to implementing caching in CodeIgniter applications. It delves into various caching strategies, including page caching, database query caching, and object caching, providing practical PHP code examples for each. By following this tutorial, developers can enhance their application's performance by reducing server load and improving\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/codesamplez.com\/category\/development"},"img":{"alt_text":"codeigniter caching guide","src":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2013\/01\/codeigniter-caching.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2013\/01\/codeigniter-caching.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2013\/01\/codeigniter-caching.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2013\/01\/codeigniter-caching.webp?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2013\/01\/codeigniter-caching.webp?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2013\/01\/codeigniter-caching.webp?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":847,"url":"https:\/\/codesamplez.com\/development\/codeigniter-best-practices","url_meta":{"origin":730,"position":4},"title":"CodeIgniter Best Practices: A Comprehensive Guide","author":"Rana Ahsan","date":"November 16, 2011","format":false,"excerpt":"This article offers essential guidelines for developing robust and scalable web applications using the CodeIgniter framework. It emphasizes organized code structure, efficient use of libraries, and performance optimization techniques, making it a valuable resource for developers aiming to enhance their CodeIgniter projects.","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/codesamplez.com\/category\/development"},"img":{"alt_text":"codeigniter best practices","src":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/11\/codeigniter-best-practices.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/11\/codeigniter-best-practices.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/11\/codeigniter-best-practices.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/11\/codeigniter-best-practices.webp?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/11\/codeigniter-best-practices.webp?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2011\/11\/codeigniter-best-practices.webp?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":24261,"url":"https:\/\/codesamplez.com\/development\/php-dependency-injection","url_meta":{"origin":730,"position":5},"title":"PHP Dependency Injection: The Ultimate Guide","author":"Rana Ahsan","date":"April 28, 2014","format":false,"excerpt":"The article \"PHP Dependency Injection With Pimple\" on CodeSamplez.com introduces developers to the concept of dependency injection in PHP using the Pimple container. It explains how Pimple facilitates managing object dependencies, promoting cleaner and more maintainable code. Through practical examples, the article demonstrates defining services and parameters within Pimple, showcasing\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/codesamplez.com\/category\/development"},"img":{"alt_text":"php dependency injection","src":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2014\/04\/php-dependency-injection.webp?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2014\/04\/php-dependency-injection.webp?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2014\/04\/php-dependency-injection.webp?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2014\/04\/php-dependency-injection.webp?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2014\/04\/php-dependency-injection.webp?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/codesamplez.com\/wp-content\/uploads\/2014\/04\/php-dependency-injection.webp?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/comments?post=730"}],"version-history":[{"count":3,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":58826,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/posts\/730\/revisions\/58826"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/media\/58777"}],"wp:attachment":[{"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/media?parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/categories?post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codesamplez.com\/wp-json\/wp\/v2\/tags?post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}