is developing the blog plug-in, need to use this project parser, how to reference the project in a php file without composer, or directly in the PHP file to install composer and this library do?
Reply content:
is developing the blog plug-in, need to use this project parser, how to reference the project in a php file without composer, or directly in the PHP file to install composer and this library do?
Use the autoloader, but it is best to use composer, after all, convenient
Https://github.com/WhichBrows ...
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');}
If not used Composer
: If the file is less direct, require
come in good, if the file involved more, look at the Library namespace usage specification is Psr4
still Psr0
, write a autoload
method, automatic introduction of files, can be referenced Composer
ClassLoader
.
If used Composer
, write one directly composer.json
and put the required library into require
.
#composer.json"require": { "php": ">=5.3.3", "godtail/db": "dev-master" #例子}#然后composer install`#引入autoload文件require '../vendor/autoload.php';
Of course, the recommended use of composer, modular, more convenient.
Install parser First
And then in the file
require 'vendor/autoload.php';
That's it.