CodeIgniter Forums
Can't use costum library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Can't use costum library (/showthread.php?tid=77697)



Can't use costum library - SimonsCode22 - 10-06-2020

Hello,
I'm a newbie to this framework and I wanted to create a simple library and load it into a Controller.

I created a library called "GmodServerAction.php" in "Libraries":
PHP Code:
<?php
namespace App\Libraries\GmodServerAction;

class 
GmodServerAction {
    public function __construct()
    {

        
    
}


Now I'm loading it in my Home-Controller:

PHP Code:
<?php namespace App\Controllers;
use 
App\Libraries\GmodServerAction\GmodServerAction;

class 
Home extends BaseShopController
{
    public function 
index()
    {

        $test = new GmodServerAction();

    
        $this
->render("home"$assign);
    }


When I'm trying to open the Homepage it just says:

Class 'App\Libraries\GmodServerAction\GmodServerAction' not found

Any idea? (Btw I'm using XAMPP)


RE: Can't use costum library - nc03061981 - 10-06-2020

namespace = path
So change to:
namespace App\Libraries;


RE: Can't use costum library - SimonsCode22 - 10-07-2020

(10-06-2020, 10:46 PM)nc03061981 Wrote: namespace = path
So change to:
namespace App\Libraries;

Thank you very much Big Grin