mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
557 lines
43 KiB
HTML
557 lines
43 KiB
HTML
<!DOCTYPE html>
|
||
<html class="writer-html5" lang="en" >
|
||
<head>
|
||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Upgrading from 3.x to 4.x — CodeIgniter 4.4.2 documentation</title>
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/css/citheme_dark.css" type="text/css" />
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<!--[if lt IE 9]>
|
||
<script src="../_static/js/html5shiv.min.js"></script>
|
||
<![endif]-->
|
||
|
||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/js/citheme.js"></script>
|
||
<script src="../_static/js/carbon.js"></script>
|
||
<script src="../_static/js/theme.js"></script>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Upgrade Models" href="upgrade_models.html" />
|
||
<link rel="prev" title="Upgrading from 4.0.x to 4.0.4" href="upgrade_404.html" />
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav">
|
||
<div class="wy-grid-for-nav">
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search" >
|
||
|
||
|
||
|
||
<a href="../index.html">
|
||
|
||
<img src="../_static/ci-logo-text.svg" class="logo" alt="Logo"/>
|
||
</a>
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/requirements.html">Server Requirements</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/credits.html">Credits</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../intro/psr.html">PSR Compliance</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../license.html">License Agreement</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul class="current">
|
||
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Installation</a><ul class="current">
|
||
<li class="toctree-l2"><a class="reference internal" href="installing_composer.html">Composer Installation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="installing_manual.html">Manual Installation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="running.html">Running Your App</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="troubleshooting.html">Troubleshooting</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../changelogs/index.html">Change Logs</a></li>
|
||
<li class="toctree-l2 current"><a class="reference internal" href="upgrading.html">Upgrading From a Previous Version</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="repositories.html">CodeIgniter Repositories</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Build Your First Application</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static Pages</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News Section</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create News Items</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../concepts/index.html">CodeIgniter4 Overview</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/structure.html">Application Structure</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/mvc.html">Models, Views, and Controllers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/autoloader.html">Autoloading Files</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/services.html">Services</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/factories.html">Factories</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/http.html">Working with HTTP Requests</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../concepts/security.html">Security Guidelines</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/configuration.html">Configuration</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helper Functions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Global Functions and Constants</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/logging.html">Logging Information</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Web Page Caching</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/ajax.html">AJAX Requests</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/modules.html">Code Modules</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../incoming/index.html">Controllers and Routing</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/routing.html">URI Routing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/controllers.html">Controllers</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/filters.html">Controller Filters</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/message.html">HTTP Messages</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/request.html">Request Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/incomingrequest.html">IncomingRequest Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/content_negotiation.html">Content Negotiation</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/methodspoofing.html">HTTP Method Spoofing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../incoming/restful.html">RESTful Resource Handling</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../outgoing/index.html">Building Responses</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/views.html">Views</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_cells.html">View Cells</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_renderer.html">View Renderer</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_layouts.html">View Layouts</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_parser.html">View Parser</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_decorators.html">View Decorators</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/table.html">HTML Table Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/response.html">HTTP Responses</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/api_responses.html">API Response Trait</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/localization.html">Localization</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../outgoing/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Working with Databases</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/events.html">Database Events</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../models/index.html">Modeling Data</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../models/model.html">Using CodeIgniter's Model</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../models/entities.html">Using Entity Classes</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../dbmgmt/index.html">Managing Databases</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/forge.html">Database Manipulation with Database Forge</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/migration.html">Database Migrations</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/seeds.html">Database Seeding</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/db_commands.html">Database Commands</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Library Reference</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/cookies.html">Cookies</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/curlrequest.html">CURLRequest Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Service</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/files.html">Working with Files</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/file_collections.html">File Collections</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/honeypot.html">Honeypot Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/images.html">Image Manipulation Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/publisher.html">Publisher</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/throttler.html">Throttler</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/time.html">Times and Dates</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/uploaded_files.html">Working with Uploaded Files</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">Working with URIs</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../libraries/validation.html">Validation</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/filesystem_helper.html">Filesystem Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/test_helper.html">Test Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html">Testing</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/overview.html">Getting Started</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/database.html">Database</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/fabricator.html">Generating Data</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/controllers.html">Controller Testing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/feature.html">HTTP Testing</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/response.html">Testing Responses</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/benchmark.html">Benchmarking</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/debugging.html">Debugging Your Application</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../testing/mocking.html">Mocking</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../cli/index.html">Command Line Usage</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_overview.html">CLI Overview</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_controllers.html">Running Controllers via CLI</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/spark_commands.html">Spark Commands</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_commands.html">Creating Spark Commands</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_generators.html">CLI Generators</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_library.html">CLI Library</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_request.html">CLIRequest Class</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../extending/index.html">Extending CodeIgniter</a><ul>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/core_classes.html">Creating Core System Classes</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/common.html">Replacing Common Functions</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/events.html">Events</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/basecontroller.html">Extending the Controller</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/authentication.html">Authentication</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/composer_packages.html">Creating Composer Packages</a></li>
|
||
<li class="toctree-l2"><a class="reference internal" href="../extending/contributing.html">Contributing to CodeIgniter</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="../libraries/official_packages.html">Official Packages</a></li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="../index.html">CodeIgniter</a>
|
||
</nav>
|
||
|
||
<div class="wy-nav-content">
|
||
<div class="rst-content">
|
||
<a class="btn btn-neutral float-right" href="https://github.com/codeigniter4/CodeIgniter4/edit/develop/user_guide_src/source/installation/upgrade_4xx.rst">Edit this page</a>
|
||
|
||
<div role="navigation" aria-label="Page navigation">
|
||
<ul class="wy-breadcrumbs">
|
||
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
|
||
<li class="breadcrumb-item"><a href="index.html">Installation</a></li>
|
||
<li class="breadcrumb-item"><a href="upgrading.html">Upgrading From a Previous Version</a></li>
|
||
<li class="breadcrumb-item active">Upgrading from 3.x to 4.x</li>
|
||
<li class="wy-breadcrumbs-aside">
|
||
</li>
|
||
</ul>
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<section id="upgrading-from-3-x-to-4-x">
|
||
<h1>Upgrading from 3.x to 4.x<a class="headerlink" href="#upgrading-from-3-x-to-4-x" title="Permalink to this headline"></a></h1>
|
||
<p>CodeIgniter 4 is a rewrite of the framework and is not backwards compatible.
|
||
It is more appropriate to think of converting your app, rather than upgrading it.
|
||
Once you have done that, upgrading from one version of CodeIgniter 4 to the next
|
||
will be straightforward.</p>
|
||
<p>The “lean, mean and simple” philosophy has been retained, but the
|
||
implementation has a lot of differences, compared to CodeIgniter 3.</p>
|
||
<p>There is no 12-step checklist for upgrading. Instead, start with a copy
|
||
of CodeIgniter 4 in a new project folder,
|
||
<a class="reference internal" href="index.html"><span class="doc">however you wish to install and use it</span></a>,
|
||
and then convert and integrate your app components.
|
||
We’ll try to point out the most important considerations here.</p>
|
||
<p>To upgrade your project, we figured out two major tasks you have to work on.
|
||
First of all, there are some general adjustments which are significant to every
|
||
project and have to be handled. The second one are the libraries in which
|
||
CodeIgniter is built up and contain some of the most important functions.
|
||
These libraries operate separately from each other, so you have to look at
|
||
them one by one.</p>
|
||
<p><strong>Do read the user guide</strong> before embarking on a project conversion!</p>
|
||
<div class="contents local topic" id="contents">
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="#general-adjustments" id="id2">General Adjustments</a></p>
|
||
<ul>
|
||
<li><p><a class="reference internal" href="#downloads" id="id3">Downloads</a></p></li>
|
||
<li><p><a class="reference internal" href="#namespaces" id="id4">Namespaces</a></p></li>
|
||
<li><p><a class="reference internal" href="#application-structure" id="id5">Application Structure</a></p></li>
|
||
<li><p><a class="reference internal" href="#routing" id="id6">Routing</a></p></li>
|
||
<li><p><a class="reference internal" href="#model-view-and-controller" id="id7">Model, View and Controller</a></p></li>
|
||
<li><p><a class="reference internal" href="#class-loading" id="id8">Class Loading</a></p></li>
|
||
<li><p><a class="reference internal" href="#libraries" id="id9">Libraries</a></p></li>
|
||
<li><p><a class="reference internal" href="#helpers" id="id10">Helpers</a></p></li>
|
||
<li><p><a class="reference internal" href="#hooks" id="id11">Hooks</a></p></li>
|
||
<li><p><a class="reference internal" href="#extending-the-framework" id="id12">Extending the Framework</a></p></li>
|
||
</ul>
|
||
</li>
|
||
<li><p><a class="reference internal" href="#upgrading-libraries" id="id13">Upgrading Libraries</a></p></li>
|
||
</ul>
|
||
</div>
|
||
<section id="general-adjustments">
|
||
<h2><a class="toc-backref" href="#id2">General Adjustments</a><a class="headerlink" href="#general-adjustments" title="Permalink to this headline"></a></h2>
|
||
<section id="downloads">
|
||
<h3><a class="toc-backref" href="#id3">Downloads</a><a class="headerlink" href="#downloads" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>CI4 is still available as a <a class="reference internal" href="installing_manual.html"><span class="doc">ready-to-run zip or tarball</span></a>.</p></li>
|
||
<li><p>It can also be installed using <a class="reference internal" href="installing_composer.html"><span class="doc">Composer</span></a>.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="namespaces">
|
||
<h3><a class="toc-backref" href="#id4">Namespaces</a><a class="headerlink" href="#namespaces" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>CI4 is built for PHP 7.4+, and everything in the framework is namespaced,
|
||
except for the helper and lang files.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="application-structure">
|
||
<h3><a class="toc-backref" href="#id5">Application Structure</a><a class="headerlink" href="#application-structure" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>The <strong>application</strong> folder is renamed as <strong>app</strong> and the framework still has <strong>system</strong> folders,
|
||
with the same interpretation as before.</p></li>
|
||
<li><p>The framework now provides for a <strong>public</strong> folder, intended as the document root for your app.</p></li>
|
||
<li><p>The <code class="docutils literal notranslate"><span class="pre">defined('BASEPATH')</span> <span class="pre">OR</span> <span class="pre">exit('No</span> <span class="pre">direct</span> <span class="pre">script</span> <span class="pre">access</span> <span class="pre">allowed');</span></code> line is not necessary
|
||
because files outside the <strong>public</strong> folder are not accessible in the standard configuration.
|
||
And CI4 no longer defines the constant <code class="docutils literal notranslate"><span class="pre">BASEPATH</span></code>, so remove the line in all files.</p></li>
|
||
<li><p>There is also a <strong>writable</strong> folder, to hold cache data, logs, and session data.</p></li>
|
||
<li><p>The <strong>app</strong> folder looks very similar to <strong>application</strong> for CI3, with some
|
||
name changes, and some subfolders moved to the <strong>writable</strong> folder.</p></li>
|
||
<li><p>There is no longer a nested <strong>application/core</strong> folder, as we have
|
||
a different mechanism for extending framework components (see below).</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="routing">
|
||
<h3><a class="toc-backref" href="#id6">Routing</a><a class="headerlink" href="#routing" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>The Auto Routing is disabled by default. You need to <a class="reference internal" href="../incoming/routing.html#defined-route-routing"><span class="std std-ref">define all routes</span></a> by default.</p></li>
|
||
<li><p>If you want to use the Auto Routing in the same way as CI3, you need to enable
|
||
<a class="reference internal" href="../incoming/routing.html#auto-routing-legacy"><span class="std std-ref">Auto Routing (Legacy)</span></a>.</p></li>
|
||
<li><p>CI4 also has an optional new more secure <a class="reference internal" href="../incoming/routing.html#auto-routing-improved"><span class="std std-ref">Auto Routing (Improved)</span></a>.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="model-view-and-controller">
|
||
<h3><a class="toc-backref" href="#id7">Model, View and Controller</a><a class="headerlink" href="#model-view-and-controller" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>CodeIgniter is based on the MVC concept. Thus, the changes on the Model, View and Controller
|
||
are one of the most important things you have to handle.</p></li>
|
||
<li><p>In CodeIgniter 4, models are now located in <strong>app/Models</strong> and you have to add the lines
|
||
<code class="docutils literal notranslate"><span class="pre">namespace</span> <span class="pre">App\Models;</span></code> along with <code class="docutils literal notranslate"><span class="pre">use</span> <span class="pre">CodeIgniter\Model;</span></code> right after the opening php tag.
|
||
The last step is to replace <code class="docutils literal notranslate"><span class="pre">extends</span> <span class="pre">CI_Model</span></code> with <code class="docutils literal notranslate"><span class="pre">extends</span> <span class="pre">Model</span></code>.</p></li>
|
||
<li><p>The views of CodeIgniter 4 have been moved to <strong>app/Views</strong>. Furthermore, you have to change
|
||
the syntax of loading views from <code class="docutils literal notranslate"><span class="pre">$this->load->view('directory_name/file_name')</span></code> to
|
||
<code class="docutils literal notranslate"><span class="pre">echo</span> <span class="pre">view('directory_name/file_name');</span></code>.</p></li>
|
||
<li><p>Controllers of CodeIgniter 4 have to be moved to <strong>app/Controllers</strong>. After that,
|
||
add <code class="docutils literal notranslate"><span class="pre">namespace</span> <span class="pre">App\Controllers;</span></code> after the opening php tag.
|
||
Lastly, replace <code class="docutils literal notranslate"><span class="pre">extends</span> <span class="pre">CI_Controller</span></code> with <code class="docutils literal notranslate"><span class="pre">extends</span> <span class="pre">BaseController</span></code>.</p></li>
|
||
<li><p>For more information we recommend you the following upgrade guides, which will give
|
||
you some step-by-step instructions to convert the MVC classes in CodeIgniter4:</p></li>
|
||
</ul>
|
||
<div class="toctree-wrapper compound">
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_models.html">Upgrade Models</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_views.html">Upgrade Views</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_controllers.html">Upgrade Controllers</a></li>
|
||
</ul>
|
||
</div>
|
||
</section>
|
||
<section id="class-loading">
|
||
<h3><a class="toc-backref" href="#id8">Class Loading</a><a class="headerlink" href="#class-loading" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>There is no longer a CodeIgniter “superobject”, with framework component
|
||
references magically injected as properties of your controller.</p></li>
|
||
<li><p>Classes are instantiated where needed, and framework components are managed
|
||
by <a class="reference internal" href="../concepts/services.html"><span class="doc">Services</span></a>.</p></li>
|
||
<li><p>The <a class="reference internal" href="../concepts/autoloader.html"><span class="doc">Autoloader</span></a> automatically handles PSR-4 style class locating,
|
||
within the <code class="docutils literal notranslate"><span class="pre">App</span></code> (<strong>app</strong> folder) and <code class="docutils literal notranslate"><span class="pre">CodeIgniter</span></code> (i.e., <strong>system</strong> folder) top level
|
||
namespaces; with Composer autoloading support.</p></li>
|
||
<li><p>You can configure the class loading to support whatever application structure
|
||
you are most comfortable with, including the “HMVC” style.</p></li>
|
||
<li><p>CI4 provides <a class="reference internal" href="../concepts/factories.html"><span class="doc">Factories</span></a> that can load a class and share the
|
||
instance like <code class="docutils literal notranslate"><span class="pre">$this->load</span></code> in CI3.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="libraries">
|
||
<h3><a class="toc-backref" href="#id9">Libraries</a><a class="headerlink" href="#libraries" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>Your app classes can still go inside <strong>app/Libraries</strong>, but they don’t have to.</p></li>
|
||
<li><p>Instead of CI3’s <code class="docutils literal notranslate"><span class="pre">$this->load->library('x');</span></code> you can now use
|
||
<code class="docutils literal notranslate"><span class="pre">$this->x</span> <span class="pre">=</span> <span class="pre">new</span> <span class="pre">\App\Libraries\X();</span></code>, following namespaced conventions for
|
||
your component. Alternatively, you can use <a class="reference internal" href="../concepts/factories.html"><span class="doc">Factories</span></a>:
|
||
<code class="docutils literal notranslate"><span class="pre">$this->x</span> <span class="pre">=</span> <span class="pre">\CodeIgniter\Config\Factories::libraries('X');</span></code>.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="helpers">
|
||
<h3><a class="toc-backref" href="#id10">Helpers</a><a class="headerlink" href="#helpers" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference internal" href="../general/helpers.html"><span class="doc">Helpers</span></a> are pretty much the same as before, though some have been simplified.</p></li>
|
||
<li><p>Since v4.3.0, you can autoload helpers by <strong>app/Config/Autoload.php</strong> as well as CI3.</p></li>
|
||
<li><p>Some helpers from CodeIgniter 3 no longer exists in Version 4. For all these
|
||
helpers, you have to find a new way to implement your functions. These
|
||
helpers are <a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/captcha_helper.html">CAPTCHA Helper</a>,
|
||
<a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/email_helper.html">Email Helper</a>.
|
||
<a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/path_helper.html">Path Helper</a>.
|
||
and <a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/smiley_helper.html">Smiley Helper</a>.</p></li>
|
||
<li><p><a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/download_helper.html">Download Helper</a>
|
||
in CI3 was removed. You need to use Response object where you are using <code class="docutils literal notranslate"><span class="pre">force_download()</span></code>.
|
||
See <a class="reference internal" href="../outgoing/response.html#force-file-download"><span class="std std-ref">Force File Download</span></a>.</p></li>
|
||
<li><p><a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/language_helper.html">Language Helper</a>
|
||
in CI3 was removed. But <code class="docutils literal notranslate"><span class="pre">lang()</span></code> is always available in CI4. See <a class="reference internal" href="../general/common_functions.html#lang" title="lang"><code class="xref php php-func docutils literal notranslate"><span class="pre">lang()</span></code></a>.</p></li>
|
||
<li><p><a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/typography_helper.html">Typography Helper</a>
|
||
in CI3 wll be <a class="reference internal" href="../libraries/typography.html"><span class="doc">Typography Library</span></a> in CI4.</p></li>
|
||
<li><p><a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/directory_helper.html">Directory Helper</a>
|
||
and <a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/file_helper.html">File Helper</a> in CI3
|
||
will be <a class="reference internal" href="../helpers/filesystem_helper.html"><span class="doc">Filesystem Helper</span></a> in CI4.</p></li>
|
||
<li><p><a class="reference external" href="https://www.codeigniter.com/userguide3/helpers/string_helper.html">String Helper</a> functions
|
||
in CI3 are included in <a class="reference internal" href="../helpers/text_helper.html"><span class="doc">Text Helper</span></a> in CI4.</p></li>
|
||
<li><dl class="simple">
|
||
<dt>In CI4, <code class="docutils literal notranslate"><span class="pre">redirect()</span></code> is completely changed from CI3’s.</dt><dd><ul>
|
||
<li><p><a class="reference external" href="https://codeigniter.com/userguide3/helpers/url_helper.html#redirect">redirect() Documentation CodeIgniter 3.X</a></p></li>
|
||
<li><p><a class="reference external" href="../general/common_functions.html#redirect">redirect() Documentation CodeIgniter 4.X</a></p></li>
|
||
<li><p>In CI4, <code class="docutils literal notranslate"><span class="pre">redirect()</span></code> returns a <code class="docutils literal notranslate"><span class="pre">RedirectResponse</span></code> instance instead of redirecting and terminating script execution. You must return it.</p></li>
|
||
<li><p>You need to change CI3’s <code class="docutils literal notranslate"><span class="pre">redirect('login/form')</span></code> to <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">redirect()->to('login/form')</span></code>.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section id="hooks">
|
||
<h3><a class="toc-backref" href="#id11">Hooks</a><a class="headerlink" href="#hooks" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p><a class="reference external" href="https://www.codeigniter.com/userguide3/general/hooks.html">Hooks</a> have been
|
||
replaced by <a class="reference internal" href="../extending/events.html"><span class="doc">Events</span></a>.</p></li>
|
||
<li><p>Instead of CI3’s <code class="docutils literal notranslate"><span class="pre">$hook['post_controller_constructor']</span></code> you now use
|
||
<code class="docutils literal notranslate"><span class="pre">Events::on('post_controller_constructor',</span> <span class="pre">['MyClass',</span> <span class="pre">'MyFunction']);</span></code>, with the namespace <code class="docutils literal notranslate"><span class="pre">CodeIgniter\Events\Events;</span></code>.</p></li>
|
||
<li><p>Events are always enabled, and are available globally.</p></li>
|
||
<li><p>The hook point <code class="docutils literal notranslate"><span class="pre">pre_controller</span></code> and <code class="docutils literal notranslate"><span class="pre">post_controller</span></code> have been removed.
|
||
Use <a class="reference internal" href="../incoming/filters.html"><span class="doc">Controller Filters</span></a> instead.</p></li>
|
||
<li><p>The hook point <code class="docutils literal notranslate"><span class="pre">display_override</span></code> and <code class="docutils literal notranslate"><span class="pre">cache_override</span></code> have been removed.
|
||
Because the base methods have been removed.</p></li>
|
||
<li><p>The hook point <code class="docutils literal notranslate"><span class="pre">post_system</span></code> has moved just before sending the final rendered
|
||
page.</p></li>
|
||
</ul>
|
||
</section>
|
||
<section id="extending-the-framework">
|
||
<h3><a class="toc-backref" href="#id12">Extending the Framework</a><a class="headerlink" href="#extending-the-framework" title="Permalink to this headline"></a></h3>
|
||
<ul class="simple">
|
||
<li><p>You don’t need a <strong>core</strong> folder to hold <code class="docutils literal notranslate"><span class="pre">MY_...</span></code> framework
|
||
component extensions or replacements.</p></li>
|
||
<li><p>You don’t need <code class="docutils literal notranslate"><span class="pre">MY_X</span></code> classes inside your libraries folder
|
||
to extend or replace CI4 pieces.</p></li>
|
||
<li><p>Make any such classes where you like, and add appropriate
|
||
service methods in <strong>app/Config/Services.php</strong> to load
|
||
your components instead of the default ones.</p></li>
|
||
<li><p>See <a class="reference internal" href="../extending/core_classes.html"><span class="doc">Creating Core System Classes</span></a> for details.</p></li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
<section id="upgrading-libraries">
|
||
<h2><a class="toc-backref" href="#id13">Upgrading Libraries</a><a class="headerlink" href="#upgrading-libraries" title="Permalink to this headline"></a></h2>
|
||
<ul class="simple">
|
||
<li><p>Your app classes can still go inside <strong>app/Libraries</strong>, but they don’t have to.</p></li>
|
||
<li><p>Instead of CI3’s <code class="docutils literal notranslate"><span class="pre">$this->load->library('x');</span></code> you can now use
|
||
<code class="docutils literal notranslate"><span class="pre">$this->x</span> <span class="pre">=</span> <span class="pre">new</span> <span class="pre">\App\Libraries\X();</span></code>, following namespaced conventions for
|
||
your component. Alternatively, you can use <a class="reference internal" href="../concepts/factories.html"><span class="doc">Factories</span></a>:
|
||
<code class="docutils literal notranslate"><span class="pre">$this->x</span> <span class="pre">=</span> <span class="pre">\CodeIgniter\Config\Factories::libraries('X');</span></code>.</p></li>
|
||
<li><p>Some libraries from CodeIgniter 3 no longer exists in Version 4. For all these
|
||
libraries, you have to find a new way to implement your functions. These
|
||
libraries are <a class="reference external" href="http://codeigniter.com/userguide3/libraries/calendar.html">Calendaring</a>,
|
||
<a class="reference external" href="http://codeigniter.com/userguide3/libraries/ftp.html">FTP</a>,
|
||
<a class="reference external" href="http://codeigniter.com/userguide3/libraries/javascript.html">Javascript</a>,
|
||
<a class="reference external" href="http://codeigniter.com/userguide3/libraries/cart.html">Shopping Cart</a>,
|
||
<a class="reference external" href="http://codeigniter.com/userguide3/libraries/trackback.html">Trackback</a>,
|
||
<a class="reference external" href="http://codeigniter.com/userguide3/libraries/xmlrpc.html">XML-RPC /-Server</a>,
|
||
and <a class="reference external" href="http://codeigniter.com/userguide3/libraries/zip.html">Zip Encoding</a>.</p></li>
|
||
<li><p>CI3’s <a class="reference external" href="http://codeigniter.com/userguide3/libraries/input.html">Input</a> corresponds to CI4’s <a class="reference internal" href="../incoming/incomingrequest.html"><span class="doc">IncomingRequest</span></a>.</p></li>
|
||
<li><p>CI3’s <a class="reference external" href="http://codeigniter.com/userguide3/libraries/output.html">Output</a> corresponds to CI4’s <a class="reference internal" href="../outgoing/response.html"><span class="doc">Responses</span></a>.</p></li>
|
||
<li><p>All the other libraries, which exist in both CodeIgniter versions, can be upgraded with some adjustments.
|
||
The most important and mostly used libraries received an Upgrade Guide, which will help you with simple
|
||
steps and examples to adjust your code.</p></li>
|
||
</ul>
|
||
<div class="toctree-wrapper compound">
|
||
<ul>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_configuration.html">Upgrade Configuration</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_database.html">Upgrade Database</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_emails.html">Upgrade Emails</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_encryption.html">Upgrade Encryption</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_file_upload.html">Upgrade Working with Uploaded Files</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_html_tables.html">Upgrade HTML Tables</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_localization.html">Upgrade Localization</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_migrations.html">Upgrade Migrations</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_pagination.html">Upgrade Pagination</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_responses.html">Upgrade HTTP Responses</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_routing.html">Upgrade Routing</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_security.html">Upgrade Security</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_sessions.html">Upgrade Sessions</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_validations.html">Upgrade Validations</a></li>
|
||
<li class="toctree-l1"><a class="reference internal" href="upgrade_view_parser.html">Upgrade View Parser</a></li>
|
||
</ul>
|
||
</div>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
|
||
<a href="upgrade_404.html" class="btn btn-neutral float-left" title="Upgrading from 4.0.x to 4.0.4" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
|
||
<a href="upgrade_models.html" class="btn btn-neutral float-right" title="Upgrade Models" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
|
||
</div>
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>© Copyright 2019-2023 CodeIgniter Foundation.
|
||
<span class="lastupdated">Last updated on Oct 22, 2023.
|
||
</span></p>
|
||
</div>
|
||
|
||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
|
||
</footer>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<script>
|
||
jQuery(function () {
|
||
SphinxRtdTheme.Navigation.enable(false);
|
||
});
|
||
</script>
|
||
|
||
</body>
|
||
</html> |