{"id":4749,"date":"2018-01-04T13:00:12","date_gmt":"2018-01-04T04:00:12","guid":{"rendered":"https:\/\/tadtadya.com\/?p=4749"},"modified":"2021-01-25T14:21:45","modified_gmt":"2021-01-25T05:21:45","slug":"php-composer-how-to-use-package-management","status":"publish","type":"post","link":"https:\/\/tadtadya.com\/en\/php-composer-how-to-use-package-management\/","title":{"rendered":"PHP composer, How to use package management"},"content":{"rendered":"\n<p>The php composer is a command tool for managing packages.<\/p>\n\n\n\n<p>Packages are extensions to various php functions, which can be installed as needed to efficiently create programs that implement the desired functions.<\/p>\n\n\n\n<p>I will show you how to use the composer command.<\/p>\n\n\n\n<!--more-->\n\n\n\n<div class=\"wp-block-origin-block-msg-box\"><div class=\"msgbox msgbox-notice v1\"><i class=\"fas fa-exclamation-triangle icon\"><\/i><div class=\"msg\">\n<p>This is written by a Japanese who can't speak English with the help of translation application. Sorry if it's not good.<\/p>\n<\/div><\/div><\/div>\n\n\n<div id=\"toc\" class=\"idx-lst\">\n\t<input type=\"checkbox\" class=\"chk\" id=\"idx-lst-chk\" name=\"btn\" \/>\n\t<label class=\"idx-lst-hd\" for=\"idx-lst-chk\"><i class=\"fa-solid fa-check-double\"><\/i>Contents<\/label>\n\t<div class=\"idx-lst-bd\">\n\t\t<ul class=\"idx-lst-ul\">\n\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-1\" title=\"What is a php package?\">What is a php package?<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-2\" title=\"How to install composer\">How to install composer<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-3\" title=\"How to install a package using composer\">How to install a package using composer<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt1\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-4\" title=\"Installed in the OS execution user environment\">Installed in the OS execution user environment<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt1\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-5\" title=\"Install in a php project\">Install in a php project<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt2\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-6\" title=\"Step 1. Go to the home directory of the project\">Step 1. Go to the home directory of the project<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt2\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-7\" title=\"Step 2. Run the composer initialization\">Step 2. Run the composer initialization<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt2\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-8\" title=\"Step 3, Add the package\">Step 3, Add the package<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-9\" title=\"The difference between composer.json and composer.lock files\">The difference between composer.json and composer.lock files<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-10\" title=\"Composer commands\">Composer commands<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-11\" title=\"init - Initial processing\">init - Initial processing<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-12\" title=\"require - Package addition and update\">require - Package addition and update<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-13\" title=\"install - Install all at once\">install - Install all at once<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-14\" title=\"update - Rebuild the package\">update - Rebuild the package<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-15\" title=\"show - show package information\">show - show package information<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-16\" title=\"self-update - Update the composer command\">self-update - Update the composer command<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-17\" title=\"create-project - Create a development project\">create-project - Create a development project<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-18\" title=\"dump-autoload - Rebuild class map\">dump-autoload - Rebuild class map<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-19\" title=\"validate - composer.json syntax check\">validate - composer.json syntax check<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t<li class=\"idx-lst-li idt0\">\n\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa-regular fa-hand-point-right ico\"><\/i>\n\t\t\t\t\t\t\t\t\t\t<a href=\"#index-list-20\" title=\"Summary\">Summary<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t\t\t<\/ul>\n\t<\/div>\n<\/div>\n\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-1\">What is a php package?<\/h2>\n\n\n\n<p>You can add various functions to php. These functions are available as packages on GitHub and other sites. The tool to manage these packages is composer.<\/p>\n\n\n\n<p>You can think of it as being similar to <strong><a href=\"https:\/\/tadtadya.com\/en\/python-pip-how-to-use-package-management\/\" title=\"Python pip, How to use package management\">pip<\/a><\/strong> in Python or gem in Ruby.<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><thead><tr><th>\u30d7\u30ed\u30b0\u30e9\u30e0<\/th><th>\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406<\/th><\/tr><\/thead><tbody><tr><td>PHP<\/td><td>composer<\/td><\/tr><tr><td>Python<\/td><td><a href=\"https:\/\/tadtadya.com\/en\/python-pip-how-to-use-package-management\/\" title=\"Python pip, How to use package management\"><strong>pip<\/strong><\/a><\/td><\/tr><tr><td>Ruby<\/td><td>gem<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The composer commands are used to add, update, and remove packages.<\/p>\n\n\n\n<p>Recently, frameworks such as <a href=\"https:\/\/laravel.com\/docs\/master\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Laravel official site\">Laravel<\/a> can also be easily installed using composer.<\/p>\n\n\n\n<p>If you are using php, you must use composer.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-note\">\n<p>Composer is OSS (Open Source Software), and the packages you install with composer are also OSS. You can use OSS for free, but be aware that not everything is freeware.<\/p>\n\n\n\n<p>OSS also has a license. It just allows the following.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-default\">\n<ul><li>\"Don't need the money.\"<\/li><li>\"Program modification approved.\"<\/li><li>\"Redistribution of the program is permitted.\"<\/li><\/ul>\n<\/div>\n\n\n\n<p>A detailed license is written in the configuration file.<\/p>\n\n\n\n<p>Note that it's never all 'free'.<\/p>\n\n\n\n<p>Don't think that you can do anything about it.<\/p>\n<\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-2\">How to install composer<\/h2>\n\n\n\n<p>composer is not included in php by default. You need to install it separately.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-a-link-ext alk-ex center\"><a href=\"https:\/\/tadtadya.com\/en\/php-how-to-install-composer\/\" title=\"PHP, How to install composer\"><strong>PHP, How to install composer<\/strong> <i class=\"fas fa-angle-double-right\"><\/i><\/a><\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-3\">How to install a package using composer<\/h2>\n\n\n\n<p>There are two installation methods.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-default\">\n<ul><li>Installed in the <strong><span class=\"marker-blue\">OS<\/span><\/strong> execution user environment<\/li><li>Install <strong><span class=\"marker-yellow\">only on specific php projects<\/span><\/strong> (limited to specified directories)<\/li><\/ul>\n<\/div>\n\n\n\n<h3 class=\"is-style-h3df\" id=\"index-list-4\">Installed in the OS execution user environment<\/h3>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format block\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer global require package_name<\/code><\/pre>\n<\/div>\n\n\n\n<p>The same package can be used by multiple php projects when installed on the OS execution user. Install packages that can be used commonly by multiple projects, such as static code checking tools.<\/p>\n\n\n\n<p>Use the \"require\" command to install the package. If you add the \"<strong><span class=\"marker-blue\">global<\/span><\/strong>\" option to it, it will install the package in the OS execution user environment.<\/p>\n\n\n\n<p>In this case, the home directory of the compoer will be in the following location<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><tbody><tr><td>Windows<\/td><td>C:Users{user_name}AppDataRoamingComposer<\/td><\/tr><tr><td>Mac, Linux<\/td><td>~\/.composer<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>In this home directory, a <strong><span class=\"marker-blue\">composer.json<\/span><\/strong> file and a <strong><span class=\"marker-blue\">vendor<\/span><\/strong> directory will be created.<\/p>\n\n\n\n<p>composer.json is a configuration file that contains information about the packages managed by composer.<\/p>\n\n\n\n<p>Also, the packages installed by composer will be added to the <strong><span class=\"marker-blue\">vendor<\/span><\/strong> directory.<\/p>\n\n\n\n<h3 class=\"is-style-h3df\" id=\"index-list-5\">Install in a php project<\/h3>\n\n\n\n<p>Install the packages that will be used only for the php project.<\/p>\n\n\n\n<p>Web frameworks, such as the Laravel framework, have different versions for different projects, so they must be installed in a specific project.<\/p>\n\n\n\n<p>Let's take a step-by-step look at installing it into a php project.<\/p>\n\n\n\n<h4 class=\"is-style-h4df\" id=\"index-list-6\">Step 1. Go to the home directory of the project<\/h4>\n\n\n\n<p>Go to the home directory of your php project.<\/p>\n\n\n\n<h4 class=\"is-style-h4df\" id=\"index-list-7\">Step 2. Run the composer initialization<\/h4>\n\n\n\n<p><strong><a href=\"#index-list-8\" title=\"If you already have composer in your php project, you don't need it. Please proceed to the next step.\">If you already have composer in your php project, you don't need it. Please proceed to the next step.<\/a><\/strong><\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer init<\/code><\/pre>\n<\/div>\n\n\n\n<p>Run this to enable package management in the composer of your php project.<\/p>\n\n\n\n<p>The command prompt will ask you to type various things, but you can edit them later in the configuration file, so just enter everything.<\/p>\n\n\n\n<p>Then a composer.json file will be generated in the project's home directory. The home directories of the project and the composer are the same.<\/p>\n\n\n\n<div class=\"pre-code-title\">composer.json<\/div><pre class=\"line-numbers\"><code class=\"language-json\">{\n    \"name\": \"***\/***\",\n    \"authors\": [\n        {\n            \"name\": \"***\",\n            \"email\": \"***@***\"\n        }\n    ],\n    \"require\": {}\n}<\/code><\/pre>\n\n\n\n<p>(**** will be created as appropriate depending on the environment)<\/p>\n\n\n\n<p>If you run the composer command in the home directory of the php project, you can add packages and so on only in the php project.<\/p>\n\n\n\n<h4 class=\"is-style-h4df\" id=\"index-list-8\">Step 3, Add the package<\/h4>\n\n\n\n<p>To install using composer, simply run the following command<\/p>\n\n\n\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer require pagekage_name<\/code><\/pre>\n\n\n\n<p>This is the same as removing the <strong><span class=\"marker-blue\">global<\/span><\/strong> option from the command to install in the OS user environment.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-9\">The difference between composer.json and composer.lock files<\/h2>\n\n\n\n<p>The composer.json and <strong><span class=\"marker-blue\">composer.lock<\/span><\/strong> files are the same in that they contain package dependencies. However, there is a crucial difference.<\/p>\n\n\n\n<p>composer.json is a configuration file. On the other hand, composer.lock is a result file that is created when you run a command in composer that changes the package dependencies.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-note\">\n<p>You can also edit the composer.json file directly.<\/p>\n\n\n\n<p>However, <strong><span class=\"marker-pink\">do not edit<\/span><\/strong> the composer.lock file directly. This is because it is a result file that is automatically written out.<\/p>\n<\/div>\n\n\n\n<p>composer.json exports the packages installed by composer. However, it does not control which packages the package further depends on.<\/p>\n\n\n\n<p>This dependent package is not written in composer.json, only in composer.lock.<\/p>\n\n\n\n<p>Only composer.lock will contain information about all the packages you have installed.<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><tbody><tr><td>composer.json<\/td><td>A file with incomplete dependency checks for all packages.<br>Write only the packages to be installed by the user.<\/td><\/tr><tr><td>composer.lock<\/td><td>A file in which package dependencies have already been inspected.<br>Write all packages installed in the composer, including dependent packages.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"is-style-h3df\">What happens when you run 'composer install'?<\/h3>\n\n\n\n<p>This means that when you run 'composer install', the speed of the package installation will be different depending on whether or not composer.lock is present.<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter th-center\"><table><thead><tr><th>If composer.lock is missing<\/th><\/tr><\/thead><tbody><tr><td>Inspect all package dependencies from composer.json.<br>\u2193<br>Output the result to composer.lock.<br>\u2193<br>Install the package.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table aligncenter th-center\"><table><thead><tr><th>If composer.lock is present<\/th><\/tr><\/thead><tbody><tr><td>Skip dependency checking of installed packages.<br>\u2193<br>Use the composer.lock that already exists.<br>\u2193<br>Run a dependency check on composer.json for the additions and changes.<br>\u2193<br>Install the package.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If you have the composer.lock file, the installation process will be faster since it will start with the dependencies of the installed packages already checked.<\/p>\n\n\n\n<p>composer.lock is used to create a copy of a PHP project, where all packages are exactly the same, and to set up a production environment.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-10\">Composer commands<\/h2>\n\n\n\n<p>There are many different composer subcommands that can be used. Here are some of the most commonly used ones.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-11\">init - Initial processing<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer init<\/code><\/pre>\n<\/div>\n\n\n\n<p>This is the initialization process for package management. Basically, it is executed only once at the beginning.<\/p>\n\n\n\n<p>Create a composer.json file in your composer home directory, which will contain the packages added to your environment and their versions, as well as the packages for your development environment and other package related settings.<\/p>\n\n\n\n<p>If you run it while composer.json is present, it will overwrite the contents of composer.json.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-12\">require - Package addition and update<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format block\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer [global] require\u00a0package_name<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><tbody><tr><td>global<\/td><td>OS execution user installation options<\/td><\/tr><tr><td>package_name<\/td><td>Package Name<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n\n<p>Used to add or update packages, add packages to the composer.json file, or update the version of an existing package.<\/p>\n\n\n\n<p>Also, update composer.json and composer.lock. composer.lock will output the package installation information. This file can be shared to easily create the same php environment.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-note\">\n<p>Updates can also be done with the <strong><a href=\"#index-list-14\" title=\"update command\">update command<\/a><\/strong>.<\/p>\n<\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-13\">install - Install all at once<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer install<\/code><\/pre>\n<\/div>\n\n\n\n<p>If you have composer.lock, use it, if not, create a new composer.lock from composer.json and build the php environment.<\/p>\n\n\n\n<p>There are situations where you need to create the same environment in the development site, so this is the time to use it.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-default\">\n<ul><li>Build a production environment from a development environment.<\/li><li>Build a local virtual environment from the development server.<\/li><li>Build multiple servers in the same environment for load balancing. etc\u2026<\/li><\/ul>\n<\/div>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-note\">\n<p>The install command will scan all packages in composer.json and composer.lock.<\/p>\n\n\n\n<p>The require command specifies the package individually.<\/p>\n<\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-14\">update - Rebuild the package<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format block\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer update\u00a0[package_name]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><tbody><tr><td>package_name<\/td><td>Package name.<br>If omitted, all packages are rebuilt.<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n\n<p>Rebuild the package resources from the composer.json file, ignoring the contents of composer.lock for the current installation status. Then, regenerate the composer.lock.<\/p>\n\n\n\n<p>This is used when you edit the composer.json file directly, such as changing the version of a package.<\/p>\n\n\n\n<p>It will be used frequently during development, but when it is used in production, it will be used only for upgrade work.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-15\">show - show package information<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format block\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer show\u00a0[package_name]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table aligncenter\"><table><tbody><tr><td>package_name<\/td><td>Package name.<br>If omitted, information on all packages is displayed.<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n\n<p>Displays information about the installed packages.<\/p>\n\n\n\n<p>If the package name is omitted, the package list is displayed. If the package name is specified, the detailed information of the package is displayed.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-16\">self-update - Update the composer command<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer self-update<\/code><\/pre>\n<\/div>\n\n\n\n<p>Run an update of the composer command.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-17\">create-project - Create a development project<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format block\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer create-project\u00a0package_name\u00a0path\u00a0ver<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>package_name<\/td><td>Package Name.<\/td><\/tr><tr><td>path<\/td><td>Installation location.<br>Project home path.<\/td><\/tr><tr><td>ver<\/td><td>2.1.1<br>*<br>2.1.*<br>2.*<br>(* select latest)<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n\n<p>You can create projects using Composer, including the web framework Laravel. This allows you to build an environment easily and quickly.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-18\">dump-autoload - Rebuild class map<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer dump-autoload<\/code><\/pre>\n<\/div>\n\n\n\n<p>Rebuild the class map used by the class autoloading feature. The package versioning will not be changed.<\/p>\n\n\n\n<p>Used in environments where class autoloading is used. Use this command to update the class map when you add or remove classes.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-a-link-ext alk-ex center\"><a href=\"https:\/\/tadtadya.com\/en\/php-composer-lets-make-effective-use-of-autoload-function\/\" title=\"PHP composer, Let's make the most of autoload !\"><strong>PHP composer, Let's make the most of autoload !<\/strong> <i class=\"fas fa-angle-double-right\"><\/i><\/a><\/div>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-19\">validate - composer.json syntax check<\/h2>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-format\">\n<div class=\"pre-code-title\"><\/div><pre class=\"\" data-user=\"root\" data-output=\"\"><code class=\"language-bash\">composer validate<\/code><\/pre>\n<\/div>\n\n\n\n<p>This is a syntax check of composer.json, run after directly editing composer.json to check for errors in your edits.<\/p>\n\n\n\n<p>Make sure you run composer.json after editing it.<\/p>\n\n\n\n<h2 class=\"is-style-h2df\" id=\"index-list-20\">Summary<\/h2>\n\n\n\n<p>This is not the only way to use composer.<\/p>\n\n\n\n<p>There are also many other important things to know, such as how to set up a test package, and how to use different commands for development and production environments.<\/p>\n\n\n\n<p>For now, I've only introduced the minimum usage.<\/p>\n\n\n\n<p>I'll be adding other details on how to use it in the future.<\/p>\n\n\n\n<div class=\"wp-block-origin-block-em-box em-group em-group-reference\">\n<p><strong><a href=\"https:\/\/getcomposer.org\/doc\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Official Composer Documentation\">Official Composer Documentation<\/a><\/strong><\/p>\n<\/div>\n\n\n\n<p><\/p>\n\n<!-- WP QUADS Content Ad Plugin v. 2.0.65.1 -->\n<div class=\"quads-location quads-ad2\" id=\"quads-ad2\" style=\"float:none;margin:0px;\">\n<ul class=\"quads-location-ul\">\r\n<li class=\"quads-location-li li-1\">\r\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-4926008942376207\"\r\n     data-ad-slot=\"6550760310\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n<\/li>\r\n<li class=\"quads-location-li li-2\">\r\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-4926008942376207\"\r\n     data-ad-slot=\"6550760310\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n<\/li>\r\n<\/ul>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>The php composer is a command tool for managing packages. Packages are extensions to various php functions, which can be installed as needed to efficiently create programs that implement the desired functions. I will show you how to use the composer command.<\/p>\n","protected":false},"author":1,"featured_media":12485,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"php composer: How to use package management\r\n\r\n#php_How_to_use_composer","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[9,43,179],"tags":[265,369],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/tadtadya.com\/en\/wp-content\/uploads\/sites\/2\/2018\/10\/php-1.png?fit=1280%2C671&ssl=1","jetpack_sharing_enabled":false,"jetpack_shortlink":"https:\/\/wp.me\/p8Qw77-1eB","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/posts\/4749"}],"collection":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/comments?post=4749"}],"version-history":[{"count":0,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/posts\/4749\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/media\/12485"}],"wp:attachment":[{"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/media?parent=4749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/categories?post=4749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tadtadya.com\/en\/wp-json\/wp\/v2\/tags?post=4749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}