Composer php установка debian

Как установить PHP Composer на Debian 11

hosting.energy недорогой хостинг сайтов

hosting.energy недорогой хостинг сайтов

В этом руководстве мы покажем вам, как установить PHP Composer на Debian 11. Для тех из вас, кто не знал, Composer — это менеджер зависимостей проекта для программирования PHP. Composer предоставляет стандартный формат для управления всеми зависимостями программного обеспечения PHP и необходимых библиотек путем загрузки всех необходимых пакетов PHP для вашего проекта и управления ими за вас. Он используется в большинстве современных PHP-фреймворков, таких как Laravel , Drupal, Magento и Symfony.

В этой статье предполагается, что у вас есть хотя бы базовые знания Linux, вы знаете, как использовать оболочку, и, что наиболее важно, вы размещаете свой сайт на собственном VPS. Установка довольно проста и предполагает, что вы работаете с учетной записью root, в противном случае вам может потребоваться добавить ‘ sudo ‘ к командам для получения привилегий root. Я покажу вам пошаговую установку PHP Composer на Debian 11 (Bullseye).

Установите PHP Composer на Debian 11 Bullseye

Шаг 1. Перед установкой любого программного обеспечения важно убедиться, что ваша система обновлена, выполнив следующие apt команды в терминале:

sudo apt update sudo apt upgrade sudo apt install curl wget php-common php-cli php-gd php-mysql php-curl php-intl php-mbstring php-bcmath php-imap php-xml php-zip git unzip

Шаг 2. Установка PHP Composer в Debian 11.

Теперь мы устанавливаем Composer в систему Debian, вам нужно выполнить эту единственную команду:

wget -O composer-setup.php https://getcomposer.org/installer

Чтобы установить Composer глобально внутри каталога, выполнив следующую команду: /usr/ local / bin

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Проверяем установленную версию:

Затем проверьте установку Composer с помощью следующей команды:

______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.1.8 2021-09-18 14:22:11 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. --no-cache Prevent use of the cache -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Шаг 3. Использование PHP Composer.

Сначала создайте каталог проекта Composer:

mkdir ~/my-composer-project cd ~/my-composer-project

Затем выполните следующую команду, чтобы инициализировать новый файл composer.json и установить пакет carbon:

composer require nesbot/carbon

После того , как установка будет завершена, вы можете увидеть , что композитор создал два файл и вместе с каталогом: composer . json composer . lock vendor

root@computerfreaks.top: ~/my-composer-project# ls -l total 28 -rw-r--r-- 1 root root 60 Sep 6 08:21 composer.json -rw-r--r-- 1 root root 18210 Sep 6 08:21 composer.lock drwxr-xr-x 6 root root 4096 Sep 6 08:21 vendor

После этого создайте новый файл с именем и вставьте следующий файл: testing . php

Читайте также:  METANIT.COM

Затем запустите сценарий, выполнив следующую команду:

root@computerfreaks.top:~/my-composer-project# php testing.php Now: 2021-09-30 08:33:21

Поздравляю! Вы успешно установили PHP Composer . Благодарим за использование этого руководства для установки последней версии PHP Composer на Debian 11 Bullseye. Для получения дополнительной помощи или полезной информации мы рекомендуем вам посетить официальный сайт Composer .

Источник

How to Install PHP Composer on Debian 12/11/10

LinuxCapable

PHP Composer is a powerful tool that helps manage dependencies in PHP projects. It works by specifying the dependencies in a file called composer.json and then running the composer command to install or update them. Incorporating PHP Composer into your Debian system can bring numerous advantages to your development process. The following are some of the key features of PHP Composer:

  • Dependency management: Composer allows you to specify your project’s dependencies and automatically installs and updates them.
  • Autoloading: Composer automatically generates the autoloader for your project, making it easy to include the needed classes without manually requiring them.
  • Version constraints: Composer allows you to specify version constraints for your dependencies, ensuring that your project always uses compatible versions of the packages it depends on.
  • Package discovery: Composer makes it easy to discover new packages by searching through a central repository.
  • Community standards: Composer follows the PSR-4 standard for autoloading, which is widely used in the PHP community, making it easy to integrate with other projects and libraries.

This tutorial guides you through downloading and installing PHP Composer on Debian 11 Bullseye or Debian 10 Buster. Additionally, you will learn about the dependencies required for PHP Composer and examples of how to use it.

Читайте также:  Php str padding left

Step 1: Update Debian

Before we begin, we must ensure that our package list is up-to-date. To do this, open up a terminal and run the following command.

The following command can be used to view available updates for review or knowledge purposes.

The below command can update any packages that are no longer current on your system.

Step 2: Install PHP

To use PHP Composer, we must first have PHP installed on our system. To install PHP on Debian, run the following command.

The command given will install the standard Debian repository version of PHP. If you want to install a different version of PHP or the latest stable release, check out my guide on installing the latest version of PHP on Debian.

Step 3: Install PHP Composer

Installing PHP Composer globally on Linux is a great way to make the tool available to all users on your system. Here are the steps to install PHP Composer globally on Linux.

Open a terminal and run the following command to download the Composer installer:

curl -sS https://getcomposer.org/installer -o composer-setup.php

If the curl command fails, you may need to install the package.

Run the following command for users that desire the Global installation of Composer.

sudo php composer-setup.php --install-dir=bin --filename=composer

example installing php composer terminal output on debian 11 or 10 linux

Once Composer is installed globally, all users on the system can use it.

Alternatively, if you want to install Composer in a specific directory, you can specify the directory in the –filename= option, for example.

sudo php composer-setup.php --install-dir=/usr/local/composer --filename=phpcomposer

You can also add the directory to your PATH by editing the .bashrc or .bash_profile file, for example:

echo 'export PATH="$PATH:/usr/local/composer"' >> ~/.bashrc

This way, you can use the Composer command from any directory.

Step 4: Verify installation

To verify that PHP Composer has been installed correctly, run the following command.

You should see the version of the Composer along with the usage instructions.

php composer version output and commands on debian 11 or 10 linux

Once PHP Composer is installed, you can use it to manage the dependencies of your PHP projects. For example, you can run the following command to create a new project with PHP Composer.

composer create-project --prefer-dist laravel/laravel myproject

This command will create a new Laravel project in a directory called “myproject.” You can also use the composer command to install and update dependencies in an existing project. For example, you can run the following command to add a new package to your project.

Читайте также:  Php substr неправильно работает

And to update a current package, you can run the following command.

Conclusion: Installing PHP Composer on Debian

In conclusion, PHP Composer is a powerful tool that simplifies managing dependencies in PHP projects. Following the steps outlined in this article, you can easily install PHP Composer on Debian and start using it to improve your development workflow. It’s also worth noting that Composer is an essential tool for modern PHP development, and it’s widely used by developers worldwide, so it’s a good idea to have it installed on your system. Additionally, if you are working on a team, having a common dependency management tool like Composer can help ensure that everyone is using identical versions of the packages, which can prevent compatibility issues.

If you’re interested in diving deeper into PHP Composer, Debian Linux, or PHP development in general, the following resources and links will be helpful for expanding your knowledge and staying up-to-date with the latest developments.

  1. PHP Composer Official Website: The official website for PHP Composer is an invaluable resource for detailed information, documentation, and updates. Visit https://getcomposer.org/ to explore the wealth of information available.
  2. Debian Linux Official Website: To learn more about Debian Linux, visit the official website at https://www.debian.org/. Here, you can find documentation, support, and news related to the Debian Linux operating system.
  3. PHP.net: As the home of PHP, https://www.php.net/ is the best place to find information on PHP development, including documentation, tutorials, and news on the latest PHP releases.
  4. Stack Overflow: Stack Overflow is a popular community-driven platform where you can find answers to technical questions or ask your own. Check out the PHP Composer tag and the Debian tag for discussions and solutions related to your topic.
  5. GitHub: The PHP Composer GitHub repository is an excellent place to find the latest source code, report issues, and contribute to the project.

Источник

Оцените статью