We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Loading external library

How to load external library inside phalcon php code ? For example, I want to use HTTPFUL library from https://phphttpclient.com/ inside phalcon php application

The easiest way is to include it in your bootstrap file in your DI container. You can include an external library and instantiate it just like you do with the DB connection or Volt.



98.9k
Accepted
answer

According to the library documentation, you can use:

1) A Phar file:

<?php
// Point to where you downloaded the phar
include './httpful.phar';

// And you're ready to go!
$response = \Httpful\Request::get('https://example.com')->send();
...

or

2) Composer:

{
    "require": {
        "nategood/httpful": "*"
    }
}

Check how dependencies are loaded using Composer in Vokuro:



24.2k

Thanks for the help. Anyway I am trying the code.