We are developing a blog plug-in and need to use this project Parser. How to reference this project in the PHP file without composer, or directly install composer and this library in the PHP file?
We are developing a blog plug-in and need to use this project Parser. How to reference this project in the PHP file without composer, or directly install composer and this library in the PHP file?
You can just use an autoloader, but it’s better to use composer, it’s more convenient after all
https://github.com/WhichBrows...
<code>function InstallComposer() { file_put_contents(__DIR__ . '/composer-setup.php', file_get_contents('https://getcomposer.org/installer')); shell_exec('php composer-setup.php'); } function InstallParser(){ shell_exec('php composer.phar require whichbrowser/parser'); }</code>
If you don’t use Composer
: If there are few files, just require
comes in. If there are many files involved, check whether the namespace usage specification of the library is Psr4
or Psr0
, and write an autoload
method. To automatically import files, you can refer to ClassLoader
of Composer
.
If you use Composer
, just write a composer.json
and put the required libraries into require
.
<code>#composer.json "require": { "php": ">=5.3.3", "godtail/db": "dev-master" #例子 } #然后 composer install` #引入autoload文件 require '../vendor/autoload.php'; </code>
Install parser first
and then add the file
<code>require 'vendor/autoload.php';</code>
That’s it