CakePHP: Performance Considerations_PHP Tutorial
1. Use of $uses and loadModel
Try not to use $uses in CakePHP 1.3.x version, because this will load all the used models, occupy memory and consume unnecessary time.
On the contrary, where you need to use the model, use loadModel to load it. If no associated data is required, set its recursive property to -1.
In addition, the default data model of the controller does not need to be loaded. If users_controller does not call loadModel(User), the User model and its associated models will be loaded automatically,
Just use it directly in the controller:
$this->User... ;
$this->User->Role...
Use lazy loading technology, version 1.3 has a lazy_model, replace the base class of your app_model with LazyModel,
will cause the model to be loaded only where it is actually called.
2. Use of eval and requestAction
Try not to use eval and requestAction. eval will cause a new script parsing process, and requestAction is equivalent to issuing a new request.
eval can be replaced with {} or $$ similar syntax, such as
case 1
$this->{$this->modelClass}->hasField("country_id");
-------------------------------------------------- ------------------
case 2
$foo = city;
$$foo = shanghai;
requestAction is replaced with view/helper
3. Cache
Use memcached where distributed data sharing is required, and try to use Apc for local data. Where Cache::write/read is used, specify which Cache configured in core.php is used through parameters.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

In this chapter, we are going to learn the following topics related to routing ?

To work on file upload we are going to use the form helper. Here, is an example for file upload.
