Skip to content

marciioluucas/phiber

Repository files navigation

HitCount Build Status Codacy Badge Scrutinizer Code Quality GitHub issues GitHub forks GitHub stars GitHub license Twitter

Phiber - ALPHA version 1.2

Imgur

Phiber is a simple ORM framework that helps you code your applications faster.

  • MySQL integration
  • Object Orientation
  • Without SQL

New Features!

  • Persistence
  • Build websites, apps and api without a single SQL query line.
  • Choose if you wanna make your SQL manually or by Object Mapping.

You can also:

  • See generated SQL
  • Activate console logs.

This library has been made by a Internet Systems Tecnology's student from Morrinhos - GO, Brazil.

IFGoiano

Creator [Márcio Lucas]

I made this library to increase my knowledge and to help my programmer friends build apps in PHP faster, because I see big difficulty to build SQLs and i think it is very boring.

This library are in alpha test, I don't recommend to production environments.

Technology

Phiber uses just pure PHP and until now only has been builded the part to MySQL 5.5+. *In the next versions we will implement in BDs like PostgreSQL and Oracle.

Dependencies

Phiber have only depdencies with Composer.

Installation

Phiber requires PHP 5.3.3+ to run and MySQL 5.5+.

Installing Phiber in your project.

The Phiber instalation is made by Composer, using the console code below:

$ composer require marciioluucas/phiber

Config

To configure Phiber is very simple, you have to create an archive called phiber_config.json in your project root path same like this.

$ROOT_PROJECT_PATH/phiber_config.json

{
  "phiber": {
    "language": "pt_br", 
    "link": {
      "database_technology": "mysql", 
      "database_name": "phiber_test", 
      "url": "mysql:host=localhost;dbname=teste_phiber", 
      "user": "root", 
      "password": "", 
      "connection_cache": true 
    },
    "log": true, 
    "execute_queries": true
  }
}

Examples

InnerJoin example:
$phiber = new Phiber();

$phiber->setTable("user");
$phiber->setFields(["user.id","user.name","user.email"]);
$phiber->add($phiber->restrictions->join("user_address", ["pk_user", "fk_user"]));
$phiber->add($phiber->restrictions->and($phiber->restrictions->equals("user.id","1"), $phiber->restrictions->like("user.name","Marcio") ));
$phiber->add($phiber->restrictions->limit(15));
$phiber->add($phiber->restrictions->offset(5));
$phiber->add($phiber->restrictions->orderBy(['user.id ASC']));
$phiber->select(); // Execute query
echo $phiber->show(); // After execute, prints the generated query
Generate->
SELECT user.id, user.name, user.email FROM user INNER JOIN user_address ON pk_user = fk_user  WHERE (user.id = :condition_user.id AND user.name LIKE CONCAT('%',:condition_user.name,'%')) ORDER BY user.id ASC LIMIT 15  OFFSET 5;

TODOS:

  • In the create method, make the support for the composition and others.
  • Split classes correctly
  • Do Relationables tables

License

MIT

Free Software, Hell Yeah!

Releases

No releases published

Packages

No packages published

Languages