PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

[FIXED] How to use composer packages embed/embed inside codeigniter

 January 20, 2022     codeigniter, composer-php, php     No comments   

Issue

I am successfully installed embed/embed inside my project. Getting error Fatal error: Class 'Embed' not found, anyone tell me how to fix this problem.

class Home extends MY_Controller {

    public function og_test()
    {
        //Load any url:
        $info = Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE');

        //Get content info

        $info->title; //The page title
        $info->description; //The page description
        $info->url; //The canonical url
        $info->type; //The page type (link, video, image, rich)
        $info->tags; //The page keywords (tags)

    }

}

Solution

Install your repository('composer require embed/embed') via composer on your project root/home, where you can find default index.php.

Go to application>config>Config.php.

Look for $config['composer_autoload'].

It will be set to FALSE in default, just change it to TRUE.

Use use Embed\Embed; in your controller.

Now try using it in your controller it should be accessible.

use Embed\Embed;
class Home extends MY_Controller {

    public function og_test()
    {
        //Load any url:
        $info = Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE');

        //Get content info

        echo $info->title; //The page title
        echo $info->description; //The page description
        echo $info->url; //The canonical url
        echo $info->type; //The page type (link, video, image, rich)
        echo $info->tags; //The page keywords (tags)

    }

}


Answered By - Sohail Haider
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing