Home PHP Framework YII The Yii3.0 era is coming, why not take a sneak peek?

The Yii3.0 era is coming, why not take a sneak peek?

Nov 01, 2019 pm 04:29 PM

The Yii3.0 era is coming, why not take a sneak peek?

Changes

Recommended: " Chuanzhi Podcast Yii Development Large Mall Project Video Tutorial

Just like when the Yii2.0 era came, Yii1.0 will eventually be gloomy. The launch of Yii3.0 version is bound to set off waves in the Yii framework. So what is the difference between Yii3.0 and Yii2.0? What changes have been made?

Yii3.0 Framework Introduction


The Yii3.0 framework is a skeleton application best suited for quick project creation.

#The framework contains basic functionality including user login/logout and contact pages. It includes all common configurations, allowing you to focus on adding new features to your application.

Directory structure

config/             包含应用配置public/             包含入口脚本,已发布的资源和其他公开可用的文件,例如favicon.ico和robots.txt
runtime/            包含运行时生成的文件
vendor/             包含依赖的第三方包
.env
.env.dist
composer.json
docker-compose.yml
Copy after login

Requirements


The web server supports PHP 7.1 which is the minimum requirement for the Yii3.0 framework .

Installation


If you don’t have Composer, you can install it by following the instructions on getcomposer.org.

You can then install this project template using the following command:

composer create-project --prefer-dist --stability = dev yiisoft / yii-project-template myappcd myapp
Copy after login

This gives you an empty project to which you can add the application template, see below on how to add these projects part.

Depending on your system, you may need to provide write permissions for ./runtime and ./public/assets

CLI application

If you want to install and run your own console The console application required for the command can be implemented by loading the yiisoft/yii-base-cli package.

composer require yiisoft/yii-base-cli
Copy after login

You can now run yii help to see the available commands.

API Application

If you want to create an API, you can load it by loading [yiisoft/yii-base-api](https://github.com/yiisoft/yii- base-api) package to implement

composer require yiisoft/yii-base-api
vendor/bin/yii serve -p 8081
Copy after login

You can access the API through http://localhost:8081/.

Web Application

Since web applications use client-side resources (such as CSS and Javascript), the resource allocation system is first selected

Option a: Asset-packagist and composer-merge-plugin (requires PHP only)

composer require "wikimedia/composer-merge-plugin"
composer config repositories.ap '{"type": "composer", "url": "https://asset-packagist.org"}'
composer config extra.merge-plugin.include "vendor/*/*/composer.assets.json"
Copy after login

Option b: Foxy (requires npm or yarn)

composer require "foxy/foxy:^1.0.0"
Copy after login

Now you can install the web application library and its dependencies Item

composer require yiisoft/yii-base-web
vendor/bin/yii serve
Copy after login

You should now be able to access the application at http://localhost:8080/.

You can find more available application libraries on GitHub.

Docker

Clone the repository and create an environment configuration file

cp .env.dist .env
Copy after login

To run the installation, create bash from the PHP image

docker-compose run --rm php bash
Copy after login

And run the composer command above.

Start the application stack

docker-compose up -d
Copy after login

Access via browser

http://docker.host:30080
Copy after login

Configuration


##Database

Edit the database configuration file config/db.php and add the real configuration, for example:

return [    'class' => 'yii\db\Connection',    'dsn' => 'mysql:host=localhost;dbname=yii2basic',    'username' => 'root',    'password' => '1234',    'charset' => 'utf8',
];
Copy after login

Tips: - Yii will not create it for you Database, this must be done manually before you can access it. - Inspect and edit other files in the config/ directory to customize the application as needed. - For information on basic application testing, see the README in the tests directory.

Tests


The tests are located in the tests directory.

Run directly from Docker image

docker run -it -v $PWD/yii-project:/app -w /app yiisoftware/yii2-php:7.2-apache bash
Copy after login

The above is the detailed content of The Yii3.0 era is coming, why not take a sneak peek?. 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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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)

Yii Security Hardening: Protecting Your Applications from Vulnerabilities Yii Security Hardening: Protecting Your Applications from Vulnerabilities Apr 03, 2025 am 12:18 AM

In the Yii framework, the application can be protected by the following steps: 1) Enable CSRF protection, 2) Implement input verification, and 3) Use output escape. These measures protect against CSRF, SQL injection and XSS attacks by embedding CSRF tokens, defining verification rules and automatic HTML escapes, ensuring the security of the application.

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.

Yii Interview Questions: Ace Your PHP Framework Interview Yii Interview Questions: Ace Your PHP Framework Interview Apr 06, 2025 am 12:20 AM

When preparing for an interview with Yii framework, you need to know the following key knowledge points: 1. MVC architecture: Understand the collaborative work of models, views and controllers. 2. ActiveRecord: Master the use of ORM tools and simplify database operations. 3. Widgets and Helpers: Familiar with built-in components and helper functions, and quickly build the user interface. Mastering these core concepts and best practices will help you stand out in the interview.

The Current State of Yii: A Look at Its Popularity The Current State of Yii: A Look at Its Popularity Apr 13, 2025 am 12:19 AM

YiiremainspopularbutislessfavoredthanLaravel,withabout14kGitHubstars.ItexcelsinperformanceandActiveRecord,buthasasteeperlearningcurveandasmallerecosystem.It'sidealfordevelopersprioritizingefficiencyoveravastecosystem.

Yii's Architecture: MVC and More Yii's Architecture: MVC and More Apr 11, 2025 pm 02:41 PM

Yii framework adopts an MVC architecture and enhances its flexibility and scalability through components, modules, etc. 1) The MVC mode divides the application logic into model, view and controller. 2) Yii's MVC implementation uses action refinement request processing. 3) Yii supports modular development and improves code organization and management. 4) Use cache and database query optimization to improve performance.

Yii: A Strong Framework for Web Development Yii: A Strong Framework for Web Development Apr 15, 2025 am 12:09 AM

Yii is a high-performance PHP framework designed for fast development and efficient code generation. Its core features include: MVC architecture: Yii adopts MVC architecture to help developers separate application logic and make the code easier to maintain and expand. Componentization and code generation: Through componentization and code generation, Yii reduces the repetitive work of developers and improves development efficiency. Performance Optimization: Yii uses latency loading and caching technologies to ensure efficient operation under high loads and provides powerful ORM capabilities to simplify database operations.

Yii Database Management: Advanced Active Record & Migrations Yii Database Management: Advanced Active Record & Migrations Apr 05, 2025 am 12:17 AM

Advanced ActiveRecord and migration tools in the Yii framework are the key to efficiently managing databases. 1) Advanced ActiveRecord supports complex queries and data operations, such as associated queries and batch updates. 2) The migration tool is used to manage database structure changes and ensure secure updates to the schema.

Yii RESTful API Development: Best Practices & Authentication Yii RESTful API Development: Best Practices & Authentication Apr 09, 2025 am 12:13 AM

Developing a RESTful API in the Yii framework can be achieved through the following steps: Defining a controller: Use yii\rest\ActiveController to define a resource controller, such as UserController. Configure authentication: Ensure the security of the API by adding HTTPBearer authentication mechanism. Implement paging and sorting: Use yii\data\ActiveDataProvider to handle complex business logic. Error handling: Configure yii\web\ErrorHandler to customize error responses, such as handling when authentication fails. Performance optimization: Use Yii's caching mechanism to optimize frequently accessed resources and improve API performance.

See all articles