Welcome Guest, Not a member yet? Register   Sign In
How to create a library?
#6

Example CI 4 Library

PHP Code:
<?php namespace App\Libraries;

/**
 * Class ExampleLibrary
 *
 * @package App\Libraries
 */
class ExampleLibrary
{
    /**
     * Class properties go here.
     * -------------------------------------------------------------------
     * public, private, protected, static and const.
     */


    // -------------------------------------------------------------------

    /**
     * __construct ()
     * -------------------------------------------------------------------
     *
     * Class    Constructor
     *
     * NOTE: Not needed if not setting values or extending a Class.
     *
     */
    public function __construct()
    {

    }

    // -------------------------------------------------------------------

}   // End of Name Library Class.

/**
 * -----------------------------------------------------------------------
 * Filename: ExampleLibrary.php
 * Location: ./app/Libraries/ExampleLibrary.php
 * -----------------------------------------------------------------------
 */ 

Example Controller loading the Example Library:

PHP Code:
<?php namespace App\Controllers;

use 
App\Libraries\ExampleLibrary;

/**
 * Class ExampleController
 *
 * @package App\Controllers
 */
class ExampleController extends BaseController
{
    /**
     * Class properties go here.
     * -------------------------------------------------------------------
     * public, private, protected, static and const.
     */


    // -------------------------------------------------------------------

    /**
     * __construct ()
     * -------------------------------------------------------------------
     *
     * Class    Constructor
     *
     * NOTE: Not needed if not setting values or extending a Class.
     *
     */
    public function __construct()
    {
        parent::__construct();

    }

    // -------------------------------------------------------------------

    /**
     * index ()
     * -------------------------------------------------------------------
     *
     */
    public function index()
    {
        $newExampleLibrary = new ExampleLibrary();
    }
    
    
// --------------------------------------------------------------------

}   // End of ExampleController Controller Class.

/**
 * -----------------------------------------------------------------------
 * Filename: ExampleController.php
 * Location: ./app/Controllers/ExampleController.php
 * -----------------------------------------------------------------------
 */ 

Try that.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
How to create a library? - by MatheusCastro - 12-07-2019, 11:29 AM
RE: How to create a library? - by acewebcreations - 12-07-2019, 08:51 PM
RE: How to create a library? - by ciadmin - 12-07-2019, 09:24 PM
RE: How to create a library? - by MatheusCastro - 12-08-2019, 04:27 AM
RE: How to create a library? - by Martin_Salas - 12-15-2019, 06:40 AM
RE: How to create a library? - by InsiteFX - 12-15-2019, 09:33 AM
RE: How to create a library? - by Martin_Salas - 12-15-2019, 03:12 PM
RE: How to create a library? - by miqueiaspenha - 07-02-2020, 12:26 PM
RE: How to create a library? - by cvlancvlan - 06-30-2020, 09:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB