Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i Connecting Composer libraries to Php site / ~#root -i
  • RU
  • UA
  • EN
  • Create an online store
  • Documentation
  • Blog
    • Unix ОS
    • Php
    • MySQL
    • JavaScript
    • Package Managers
    • Docker
    • Seo
  • Short Links
  • Sign in
  • Create Account
  • Home
  • Package Managers
  • Connecting Composer libraries to Php site

Connecting Composer libraries to Php site

Having understood the basic commands and the basics of how to work with Composer , we can begin to integrate it into our project.

Our project :

The project will have this simple structure for example

Структура проекта

It will only contain the index.php file. The rest is already created by Composer itself.

What do we connect :

For example, let's include symfony/var-dumper from Symfony. Our /var/www/proj.loc/composer.json looks like this:

{
"name": "username/proj.loc",
"description": "Description",
"type": "proj.loc",
"license": "free",
"authors": [
{
"name": "username",
"email": "ad@min.loc"
}
],
"require": {
"symfony/var-dumper": "^2.0"
}
}

We do in the root of the project /var/www/proj.loc/ :

composer install

this creates a vendor folder. We need her. It will contain autoload.php .

We connect :

In the index.php file we place the autoload.php connection

<?php
include_once './vendor/autoload.php';

dump($_SERVER);>

If everything went well, then from the library pulled through Composer, the dump () function will become available;

dumper

01 June 18
807
0

Comments

Name
E-mail
Rating
Review

Other articles from the category

03 June 2018

Installing Propel in our project via Composer

Let's pull Propel2 ORM into our project using Composer. Let's take a look at the related packages needed for Propel2.

31 May 2018

Getting started with Composer on Ubuntu 14.04

Composer brought the convenience of using ready-made solutions, packages and libraries. Proper organization of work with Composer can make it easy to maintain always up-to-date versions of the libraries used in the project. Consider getting started with Composer.

Categories

  • Unix OS
  • Php
  • MySQL
  • JavaScript
  • Package Managers
  • Docker
  • Seo

Latest comments

alex, я вижу 2 причины почему так может быть. Не в...
root-i
04.07.22
Сделал все так как написано в статье, не работает.
alex
04.07.22
Как вариант это может происходить из-за неизвестно...
root-i
21.01.22
Чтобы убрать ошибку Uncaught TypeError: $ is not a...
wlad2.ru
11.01.22

I share information in which I needed help and spent a lot of time figuring it out. If the information helped at least one person, then this site was not created in vain.

Thank you for the continuation of the site:
Contacts

Telegram Viber Mail

Search for articles

  • Sign in
  • Create Account

Powered by chmod -R