composer one

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:05:46
Original
1180 people have browsed it

composer is a PHP package library dependency management tool. If you need to know more about it, you can check the information on the official website. For PHP, composer is really a good thing. Node and npm, Python has pip, and now PHP has also caught up! Let’s try it today

1. First install it

curl -sS https://getcomposer.org/installer | php

2. After the command is run, a composer.phar file will be generated in the current directory, move it Go to the /usr/local/bin directory and install it globally.
3. Create a new composer.json

<code>touch composer<span>.json</span>
vim composer<span>.json</span></code>
Copy after login
<code><span>"require"</span>:{
                <span>"monolog/monolog"</span>:<span>"1.2.*"</span>
                }

}
</code>
Copy after login

Generate the following files in the directory

<code>root<span>@66</span>f625feefa3:~<span># ls</span>
composer<span>.json</span>  composer<span>.lock</span>  vendor</code>
Copy after login

4. When you need to use monolog, introduce 'vendor/autoload.php' in php;

<code><span><span><?php</span><span>require</span><span>'/root/vendor/autoload.php'</span>;
<span>$log</span> = <span>new</span> Monolog\Logger(<span>'name'</span>);
<span>$log</span>->pushHandler(<span>new</span> Monolog\Handler\StreamHandler(<span>'app.log'</span>, Monolog\Logger::WARNING));

<span>$log</span>->addWarning(<span>'Foo'</span>);

<span>?></span></span></span></code>
Copy after login

5.ls View there Is app.log generated

<code>root<span>@66</span>f625feefa3:~<span># ls</span>
app<span>.log</span>  composer<span>.json</span>  composer<span>.lock</span>  test<span>.php</span>  test1<span>.php</span>  vendor
</code>
Copy after login

As expected, app.log is generated

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces composer 1, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Composer failed to install TP51
From 1970-01-01 08:00:00
0
0
0
PHP study installation composer cannot be used
From 1970-01-01 08:00:00
0
0
0
php - Error using composer
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template