Please advise on PHP class library loading rules
过去多啦不再A梦
过去多啦不再A梦 2017-05-27 17:43:28
0
3
578

I have a question. . My project loads classes purely through a custom namespace. Then I will introduce a third-party class library. This class library is loaded according to the PSR-4 specification. In this case. How can I reference this third-party class library in the project without changing my original loading rules?

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
阿神

Composer introduces a third-party class library, and introduces composer's autoload.php in the entry file to automatically load the file

某草草

The project has an entry file, just require it in the entry file

洪涛

First require the third-party class library, and then use it. Then you can instantiate this class, for example:

<?php
namespace common\services\money;

require_once ROOT_PATH . '/extensions/payssion/lib/PayssionClient.php';

use PayssionClient;

class PayssionService
{
    public function test()
    {
        $payssion = new PayssionClient();
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template