PHP code example of nguyenanhung / codeigniter-framework
1. Go to this page and download the library: Download nguyenanhung/codeigniter-framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nguyenanhung / codeigniter-framework example snippets
/*
*---------------------------------------------------------------
* SYSTEM DIRECTORY NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" directory.
* Set the path if it is not in the same directory as this file.
*/
$system_path = 'system';
/*
*---------------------------------------------------------------
* SYSTEM DIRECTORY NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" directory.
* Set the path if it is not in the same directory as this file.
*/
$system_path = '/your_vendor_path/nguyenanhung/codeigniter-framework/system';
/**
* Class Hungna_test
*
* @author 713uk13m <[email protected]>
* @copyright 713uk13m <[email protected]>
*/
class Hungna_test extends HungNG_CI_Base_Controllers
{
public function __construct()
{
parent::__construct();
}
public function index()
{
echo "This is ".get_class($this); // show: This is Hungna_test
exit();
}
}
/**
* Class My_worker
*
* @author 713uk13m <[email protected]>
* @copyright 713uk13m <[email protected]>
*/
class My_worker extends HungNG_CI_Base_Queue_Worker
{
// Initializer
protected function init() {}
// Worker
protected function handleWork() {}
// Listener
protected function handleListen() {}
}
/**
* Class My_rest_api
*
* @author 713uk13m <[email protected]>
* @copyright 713uk13m <[email protected]>
*/
class My_rest_api extends HungNG_CI_Base_REST
{
public function index()
{
return $this->response->json(['bar'=>'foo']);
}
public function store($requestData=null) {
$this->db->insert('mytable', $requestData);
$id = $this->db->insert_id();
return $this->response->json(['id'=>$id], 201);
}
}
defined('BASEPATH') or exit('No direct script access allowed');
/**
* Class MY_Loader
*
* @author 713uk13m <[email protected]>
* @copyright 713uk13m <[email protected]>
*/
class MY_Loader extends HungNG_Loader
{
}
defined('BASEPATH') or exit('No direct script access allowed');
/**
* Class MY_Router
*
* @author 713uk13m <[email protected]>
* @copyright 713uk13m <[email protected]>
*/
class MY_Router extends HungNG_Router
{
}
defined('BASEPATH') or exit('No direct script access allowed');
/**
* Class TestModule
*
* @author 713uk13m <[email protected]>
* @copyright 713uk13m <[email protected]>
*/
class TestModule extends HungNG_CI_Base_Module
{
public function __construct()
{
parent::__construct();
}
public function index()
{
echo "This is ".get_class($this); // show: This is TestModule
exit();
}
}