亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home PHP Framework YII Get started using the yii framework

Get started using the yii framework

Nov 01, 2019 pm 03:47 PM
yii good frame

Get started using the yii framework

Yii installation and basic configuration

Yii is a high-performance PHP framework suitable for developing WEB 2.0 applications. You can check the features of Yii on the Yii Chinese official website (see foreign websites as well). The installation of Yii is very simple. The official provides direct download. After downloading, you can use it as long as you have a local PHP environment. You can click here to download the official Yii. In China, there may be problems with slow downloads or download failures. I have uploaded a yii-basic version. If you need it, you can click on the corresponding version to download.

Recommended study: "chuanzhipod Yii development large mall project video tutorial"

After downloading, unzip to the php environment path, I am Wampserver is installed locally, so put it directly in the site path corresponding to wampserver. After decompressing, first check whether the local PHP environment is suitable for running this version of YII. You can view the requirements.php file in the basic directory in the browser:

Get started using the yii framework

See the above prompts , indicating that the local php version supports the operation of this Yii version.

Then visit: http://localhost/basic/web/index.php. If you install it for the first time, the following error will appear

yii\web\Request::cookieValidationKey must be configured with a secret key.

We also need to perform relevant configuration before it can be used. Find the cookieValidationKey configured in the basic/config/web.php file (to prevent cookie attacks.):

Get started using the yii framework

Enter a random string and revisit the following http://localhost/ basic/web/index.php, get it done:

Get started using the yii framework

Usage of controller

controller is written uniformly in the controllers directory, and the first letter of the file name is capitalized, starting with controller At the end, and need to inherit the controller, I created a new HelloController.php file below:

Get started using the yii framework

For testing, we create a new action in HelloController.php

<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
/**
* 
*/
class HelloController extends Controller
{
    public function actionIndex()
    {
        echo "hello world";
    }
}
?>

Then open http://localhost/basic/web/index.php?r=hello/index in the browser, and the browser can display hello world

where: hello represents which controller, index represents the control Specific operations in the server

Simple processing and storage location of session

We first modify the actionIndex above, add a session

  public function actionIndex()
    {
        $session = Yii::$app->session;
        $session->open();
        $session[&#39;id&#39;]="123456";
        echo $session[&#39;id&#39;];
        echo &#39;<br/>&#39;;       
        echo "hello world";
    }

, and then enter: http in the browser ://localhost/basic/web/index.php?r=hello/index, press F12 to open the debugging window to view:

Get started using the yii framework

There is one more PHPSESSID in the cookie, PHPSESSID What is its function? We know that the session can be used to temporarily store some data information, which is valid until the browser is closed. But how does the server distinguish between different sessions? It is through sessionID, which is PHPSESSID here. The browser will send a cookie (including PHPSESSID) to the server every time it sends a request. PHP uses PHPSESSID to distinguish each session.

So where is this PHPSESSID stored? We can open the php->php.ini file and search for session.save_path:

Get started using the yii framework

According to the above path, open D:\wamp\tmp,

Get started using the yii framework

There happens to be a file, and the file name is exactly the same as the value corresponding to the PHPSESSID above

Yii stores session data as a file on the server by default. Of course, we can also Set to save the session to the data table.

The above is the detailed content of Get started using the yii framework. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

What is the difference between php framework laravel and yii What is the difference between php framework laravel and yii Apr 30, 2025 pm 02:24 PM

The main differences between Laravel and Yii are design concepts, functional characteristics and usage scenarios. 1.Laravel focuses on the simplicity and pleasure of development, and provides rich functions such as EloquentORM and Artisan tools, suitable for rapid development and beginners. 2.Yii emphasizes performance and efficiency, is suitable for high-load applications, and provides efficient ActiveRecord and cache systems, but has a steep learning curve.

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

Yii with Docker: Containerizing and Deploying Your Applications Yii with Docker: Containerizing and Deploying Your Applications Apr 02, 2025 pm 02:13 PM

The steps to containerize and deploy Yii applications using Docker include: 1. Create a Dockerfile and define the image building process; 2. Use DockerCompose to launch Yii applications and MySQL database; 3. Optimize image size and performance. This involves not only specific technical operations, but also understanding the working principles and best practices of Dockerfile to ensure efficient and reliable deployment.

What are the common misunderstandings in the learning process of Golang framework? What are the common misunderstandings in the learning process of Golang framework? Jun 05, 2024 pm 09:59 PM

There are five misunderstandings in Go framework learning: over-reliance on the framework and limited flexibility. If you don’t follow the framework conventions, the code will be difficult to maintain. Using outdated libraries can cause security and compatibility issues. Excessive use of packages obfuscates code structure. Ignoring error handling leads to unexpected behavior and crashes.

Revealing common faults and concerns in Java frameworks Revealing common faults and concerns in Java frameworks Jun 05, 2024 pm 09:37 PM

Common Java framework failure concerns: Connection pool failure: Increase the connection pool size or use monitoring tools to resolve connection pool exhaustion issues. Hibernate lazy loading exception: Explicitly initialize lazy loading entities before using them. JSON mapping errors: Verify the correctness of the data type and JSON format. Filter and interceptor configuration issues: Double check the configuration to make sure it is working as expected.

Is it easy to migrate a Laravel Project to Yii? Is it easy to migrate a Laravel Project to Yii? May 09, 2025 am 12:01 AM

Migratingalaravel Projecttoyiiishallingbutachieffable WITHIEFLEFLANT.1) Mapoutlaravel component likeroutes, Controllers, Andmodels.2) Translatelaravel's SartisancommandeloequentTooyii's giiandetiverecordeba

Yii Developer: Senior vs junior Yii Developer: Senior vs junior May 24, 2025 am 12:10 AM

The main difference between senior Yii developers and junior Yii developers is experience, depth of skills and way of thinking. 1. Senior developers pay attention to performance optimization and code reconstruction, and use Yii's cache mechanism to improve application performance. 2. They deeply understand Yii's underlying principles, participate in architectural design and technical decision-making, and use modular design to build flexible applications. 3. Senior developers pay attention to overall project planning and long-term development and play the role of mentor. Junior developers need to gradually improve through learning and practice, and eventually grow into senior developers.

See all articles