• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ThirdParty Libraries usage

#1
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'); 
Reply

#2
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.
Practical CodeIgniter 3  • CodeIgniter 4 Foundations - Coming Soon • Vulcan - CLI Tools for CI4
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.