search
HomeDevelopment ToolscomposerSolution to the slow installation of Yii2 composer

The following column of composer usage tutorial will introduce to you the solution to the slow installation of Yii2 composer.

Solution to the slow installation of Yii2 composer

It is very convenient to use composer for open source projects that reference PHP in Yii. Open source projects that reference front-end also have the composer plug-in fxp-asset (https://github.com /fxpio/composer-asset-plugin) and Asset Packagist (https://github.com/hiqdev/asset-packagist)

Yii used to use the former by default, but now the new yii2 template uses the latter by default, and the latter The author is very good. He seems to be a heavy Yii user. It seems that he was annoyed by the slow execution of fxp-asset, so he came up with an updated method.

Getting back to the point:

So the faster installation method is Asset Packagist https://asset-packagist.org

In fact, it is 2 steps:

In Turn off the call of fxp-asset in config

Add the configuration of the asset-packagist library to the source list

"config": {
        "process-timeout": 1800,
        "fxp-asset": {
            "enabled": false 
        }
    },
    
 "repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
]

If the composer source uses the Alibaba Cloud image, the complete writing is as follows:

"repositories": {
        "0": {
            "type": "composer",
            "url": "https://asset-packagist.org"
        },
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        }
    }

It should be noted that when yii defines the vendor path in yii\base\Application, it also defines the bower and npm paths:

    /**
     * Sets the directory that stores vendor files.
     * @param string $path the directory that stores vendor files.
     */
    public function setVendorPath($path)
    {
        $this->_vendorPath = Yii::getAlias($path);
        Yii::setAlias('@vendor', $this->_vendorPath);
        Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower');
        Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
    }

This is a different solution from the default installation path of asset-packagist. :

Redefine the bower and npm paths in Yii

    $config = [
        ...
        'aliases' => [
            '@bower' => '@vendor/bower-asset',
            '@npm'   => '@vendor/npm-asset',
        ],
        ...
    ];

For more composer technical articles, you can visit the composer commandUsage tutorial column!

The above is the detailed content of Solution to the slow installation of Yii2 composer. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
AI and Composer: Enhancing Code Quality and DevelopmentAI and Composer: Enhancing Code Quality and DevelopmentMay 09, 2025 am 12:20 AM

In Composer, AI mainly improves development efficiency and code quality through dependency recommendation, dependency conflict resolution and code quality improvement. 1. AI can recommend appropriate dependency packages according to project needs. 2. AI provides intelligent solutions to deal with dependency conflicts. 3. AI reviews code and provides optimization suggestions to improve code quality. Through these functions, developers can focus more on the implementation of business logic.

What Defines a Composer: Understanding the RoleWhat Defines a Composer: Understanding the RoleMay 08, 2025 am 12:07 AM

Composers are people who express emotions, tell stories or express ideas by creating musical works, whose roles include conceiving musical structures, choosing instrument combinations, and working with other musicians. 1) Composers will go through four stages of conception, creation, modification and improvement during the creative process; 2) They need to master musical theories, such as harmony, counterpoint and melody, to ensure the quality and effect of the work.

Composer: Installing, Updating, and Managing DependenciesComposer: Installing, Updating, and Managing DependenciesMay 07, 2025 am 12:07 AM

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json and composer.lock files. 1. Install Composer: Run a specific command and move composer.phar to the system path. 2. Update Composer: Use composelself-update command. 3. Dependency management: add dependencies through the composerrequire command, automatically update relevant files and download packages.

AI-Powered Composer: Code Generation and AnalysisAI-Powered Composer: Code Generation and AnalysisMay 06, 2025 am 12:11 AM

AI plays an important role in code generation and analysis: 1) generate code through machine learning and NLP, such as GitHub’s Copilot; 2) perform code analysis, identify bugs and optimization suggestions, such as SonarQube; 3) improve development efficiency and code quality, but requires manual review and optimization.

Composer: AI-Powered Tools and IntegrationsComposer: AI-Powered Tools and IntegrationsMay 05, 2025 am 12:11 AM

Composer itself does not include AI capabilities, but can be enhanced by AI tools. 1) AI can analyze composer.json files, and it is recommended to optimize dependencies and predict version conflicts. 2) AI-driven platforms such as GitHubCopilot can provide real-time code suggestions to improve development efficiency. When using AI tools, you need to verify and adjust them in combination with actual situations.

The Attributes of a Successful ComposerThe Attributes of a Successful ComposerMay 04, 2025 am 12:13 AM

The key traits of a successful composer include: 1) rich creativity and imagination, 2) solid mastery of technical skills and tools. These traits are similar to creative and structured thinking in programming, helping composers realize creativity and optimize their work in music creation.

The Requirements to Be a Composer: A Deep DiveThe Requirements to Be a Composer: A Deep DiveMay 03, 2025 am 12:08 AM

To become a composer, you need to master music theory, instrumental performance, be familiar with music style and history, and be creative and inspiring. Specific steps include: 1. Learn music theory, such as chord structure and rhythm mode; 2. Master the performance of musical instruments and improve creative inspiration; 3. Be familiar with music production software, such as AbletonLive, to improve creative efficiency; 4. Continuous practice and adjustment, create complex melodies and use discordant chords to increase music tension.

Composer: The Package Manager for PHP DevelopersComposer: The Package Manager for PHP DevelopersMay 02, 2025 am 12:23 AM

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json file. 1) parse composer.json to obtain dependency information; 2) parse dependencies to form a dependency tree; 3) download and install dependencies from Packagist to the vendor directory; 4) generate composer.lock file to lock the dependency version to ensure team consistency and project maintainability.

See all articles

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

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version