[Solved] How to load internal library into Cakephp, Laravel Framework

0
49
Hello everyone, Welcome to Learn Tech Tips Blog
          Today I will share with you how to easy using internal Library in any framework. Today we talk about Cakephp Framework.

           I had taken a lot of time to find this way, and I want to sharing with you for you easy to do it, if you make that case same as me. Don’t waste the time now we are going to the topic.

            As you know, each framework via CAKEPHP, LARAVEL, …. They all integrated autoload.php file, what autoload file used for? actually that file will auto load all related library from the project. So if you install any library. You should install by command: COMPOSER.

Example: I install the library SIMPLE  HTML DOM PARSER from Sunra. I use below command

 
Case 1: install library from composer.
composer require sunra/php-simple-html-dom-parser

After install succeed, that all file library will auto mark in our projects through autoload.php file.

When you use on CAKEPHP: you just need:

include APP . ‘Vendor’ . DS . ‘autoload.php’;

use SunraPhpSimpleHtmlDomParser;

$dom = HtmlDomParser::file_get_html(‘https://google.com’, false, null, 0);
echo $dom;

While your location of library file same as:
Vendor/sunra/…

How to load internal library into Cakephp, Laravel Framework

No need to care about how to load it.

 
Case 2: Library not load from composer, just copy from another github or any Vendor. At this case you can use this line for add library.
check index.php file of them.
App::import(“Vendor”, “phpqrcode/qrlib”);
How to load internal library into Cakephp, Laravel Framework

Similar on LARAVEL framework, just do it same this.

Any feedback or questions, leave your comment, we will discuss about it
Zidane