CodeIgniter Forums
ThirdParty Libraries usage - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: ThirdParty Libraries usage (/showthread.php?tid=68435)



ThirdParty Libraries usage - iamolo - 07-10-2017

Good day,

I have been trying to use Symfony yaml  library on my CodeIgniter4 based project , I have added the necessary dependencies using composer.

The Sysmfony library is downloaded to ThirdParty/sysmfony.

I have included the necessary Symfony\Component\Yaml\Parser namespace on my controller as the code snippet hereunder shows, however, when i run this code it results into an exception "Class 'Symfony\Component\Yaml\Parser' not found", could someone kindly guide me in the right direction , and show me how to integrate and successfully use third party libraries in CodeIgniter4.

Thank you kindly.

PHP Code:
<?php

namespace App\Controllers;

use 
Config\App;
use 
CodeIgniter\HTTP\URI;
use \
App\Libraries\BackendController;
use 
Entities\Claim;
use 
Services\ClaimService;
use 
CodeIgniter\HTTP\IncomingRequest;
use \
Config\Services;

use \
Symfony\Component\Yaml\Parser;

public function 
create() {
        /*
         * Read settings
         */
        $yaml = new Parser();
        
        $settings 
$yaml->parse(APPPATH 'Config/app_config.yaml'); 



RE: ThirdParty Libraries usage - kilishan - 07-10-2017

Being Symfony, I imagine it's all available through Composer, so just do it all through Composer. Don't worry about using the third party directory at all.

So:

1. add it as a requirement to your composer.json
2. composer update to install it
3. load the class like any other autoloaded class:

Code:
$yaml = new Parser();

That should do it.