composer 是一個包php庫依賴管理工具,需要詳細了解,可以區官網查看資料.對於php來說,composer 真的是個好東西啊, node 又npm,python有pip,現在php也跟上來啦!今天來試試
1.先來安裝
curl -sS https://getcomposer.org/installer | php
2.命令運行後會在當前目錄生成一個composer.phar檔案,把它移動到/usr/local/bin
目錄下,全域安裝啦.
3. 新建一個composer.json
<code>touch composer<span>.json</span> vim composer<span>.json</span></code>
<code><span>"require"</span>:{ <span>"monolog/monolog"</span>:<span>"1.2.*"</span> } } </code>
在目錄下產生以下檔案
<code>root<span>@66</span>f625feefa3:~<span># ls</span> composer<span>.json</span> composer<span>.lock</span> vendor</code>
4.當需要這個用monolog 的時候在php文引入'vendor/autoload.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>
5.php文引入'vendor/autoload.php';<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false"><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></pre><div class="contentsignin">登入後複製</div></div>
5.php文引入'vendor/autoload.php';
5.php文引入'vendor/autoload.php';
rrreee5.php文引入'vendorls5.麼有沒有產生app.logrrreee果然生成啦app.log').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i').text(i)); }; $numbering.fadeIn(1700); }); });
🎜 以上就介紹了composer 一,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。 🎜 🎜 🎜