Welcome Guest, Not a member yet? Register   Sign In
How to use third party library
#1

Hi,
This is maybe stupid question but I have no idea how to use third party library in my project?

I want to use http://mobiledetect.net/ library but I don't know where to put it and how to use it in my app? 
 
I tried to include it directly in my controlers but this is not correct way of doing it so please help with some instructions where to put such files?
Reply
#2

From the doc first you need to download Composer which will install it.

Once Composer is installed you need to run it from a terminal in the project root.

composer require mobiledetect/mobiledetectlib

Once installed just follow the rest of the instructions.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(09-02-2020, 03:53 AM)InsiteFX Wrote: From the doc first you need to download Composer which will install it.

Once Composer is installed you need to run it from a terminal in the project root.

composer require mobiledetect/mobiledetectlib

Once installed just follow the rest of the instructions.

Tnx, but I forgot to metnion that I will not install it with composer, but manualy include in my project. I need to put mobileDetect.php somwhere and somehow include it in app....
Reply
#4

(This post was last modified: 09-02-2020, 07:31 AM by jreklund.)

You do it like this: https://codeigniter.com/user_guide/conce...l#classmap

PHP Code:
$classmap = [
    
'MobileDetect' => APPPATH .'third_party/Mobile_Detect.php'
];

// Controller
new \MobileDetect

Depending on your needs, we kinda have it already built in:
https://codeigniter.com/user_guide/libra...l#isMobile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB