Tuesday, 21 June 2016

PHP-MYSQLI Framework/Library For PHP application Development


A lot of Frameworks are available in PHP like cakephp,laravel,symfony,wordpress,joomla,drupal.etc. But all of them have their own restrictions, you cannot query it like what u want. Because they have their own canvas & u have to study their canvas structure to actually develop something in it. But for small application & websites you do not want to  use advanced heavy frameworks. For these type of small projects, you can use corephp frameworks.

By considering this, I have developed a  PHP-MYSQLI object oreiented  framework. Here You can query as you want, If you dont want to query also, Just use framworks methods, it is very simple...

Just Download framework from here...

Download From Here: https://github.com/litto/PHP-MYSQLI-Framework.git

The Project has 3 main Folders named- core,models,lib.
In core folder  MYSQLI & DB object Library class is situated... Here You dont want to change anything... This is the actual  core of our framework...
Next is  Models folder, It is actually files describing about the tables & their fields... In it we can describe how many fields the table has, that table has any relation with other tables.etc...
Include mysqlidb and dbObject classes. If you want to use model autoloading instead of manually including them in the scripts use autoload() method.

require_once("libs/MysqliDb.php");
require_once("libs/dbObject.php");

// db instance
$db = new Mysqlidb('localhost', 'user', '', 'testdb');
// enable class autoloading
dbObject::autoload("models");
Each database table could be easily mapped into a dbObject instance. If you do not want to create model for a simple table its object could be simply created with a table() method.

$user = dbObject::table("users");
Otherwise basic model should be declared as:

class user extends dbObject {}
In case autoload is set to 'models' directory, the filename should be models/user.php

Class will be related to 'user' table. To change the table name, define correct name in the $dbTable variable:

    protected $dbTable = "users";
Both objects created throw new class file creation of with table() method will have the same set of methods available. Only exception is that relations, validation or custom model methods will not be working with an objects created with table() method.

Third folder is lib folder.. In it you can create classes, but make sure that its name should not be same as any model names placed in model directory.. The benefit of creating files in it is that, you can write simple query's you want instead of using frameworks default functions..

Then in the rootfolder you can see a file named config, in this file only we are  describing the connection parameters named database name,username,password.etc...

Please download the files from above & just install it & see the structure . I have created list file, Create file, Edit file, delete file.etc., Database can be seen in db folder. Just import in your sql database & see its working or not?. So you can easily remember the structure... If you have any doubt please contact me....