Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install composer under XAMPP

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to install composer under XAMPP, which has certain reference value, and friends who need it can refer to it. I hope you will have a lot of success after reading this article. Let's take a look at it together.

declarative relationship

Let's say you're creating a project and you need a library for logging. You decide to use Monolog. To add it to your project, all you need to do is create a> composer.json file that describes the project dependencies.

{ "require": { "monolog/monolog": "1.2.* " }}

installation

1. Download Composer-Setup.exe

2. Click Install

3, will appear, can not find a lot of php dll

I tried putting these dll files into the system32 file under drive C,

or not

I tried adding environment variables, supporting php,

or not

It was later discovered that it was because of php.ini in xampp

extension_dir = "\xampp\php\ext" is a relative path, composer cannot find the corresponding dll,

Change it to extension_dir = "D:\xampp\php\ext", and there is one more thing that needs to be changed.

browscap = "D:\xampp\php\extras\browscap.ini"

After the modification is complete, it can be installed.

use

Continue to explain, the third-party controls automatically generated by composer are generally in a folder called vendor, and the Chinese translation is 'vendor'. To use it,

require_once __DIR__ . '/vendor/autoload.php';

Or safer use,

if (is_file(__DIR__ . '/vendor/autoload.php')) { require_once __DIR__ . '/vendor/autoload.php';}

If you do not add this sentence, it will generally be reported incorrectly.

Summary: Composer downloads code files from the source of related libraries according to the declared dependencies, and generates PHP scripts for automatic class loading under Composer directory according to the dependencies. When using, introduce the file "/vendor/autoload.php" at the beginning of the project, and you can directly instantiate the classes in these third-party class libraries.

Thank you for reading this article carefully. I hope Xiaobian can share how to install composer content under XAMPP to help everyone. At the same time, I hope everyone will support you a lot. Pay attention to the industry information channel. If you encounter problems, find detailed solutions waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report