Cygnite - A Modern Toolkit For Web Developers

The Elegant Way of Building Full-Featured Web Applications

Cygnite Dynamic Routing

Welcome To Cygnite PHP Framework

Showing posts with label PHP Framework. Show all posts
Showing posts with label PHP Framework. Show all posts

WHY USE CYGNITE FRAMEWORK ?

Welcome to Cygnite Framework

A Modern PHP Framework For Web Developers

Why you'll love Cygnite Framework.


Cygnite packed with various awesome features to make your development very simple and enjoyable. You may be beginner or advance professional, Cygnite welcome you all way.


  • Cygnite uses lazy loading extensively. Which gives you excellent performance with or without any caching mechanism.

  • You may be beginner or advance professional, Cygnite is powerful enough for any kind of users.

  • Cygnite is powered by awesome tool Composer. You may plug and play with third party libraries into Cygnite from Packagist.

Cygnite Framework Is Best for You if..

  • You need an lightweight framework
  • You need exceptional performance
  • You want to develop application on deadline
  • You like simple, easy to use, and well documented framework.
  • Don't want to spend lot of time on configuring things
  • You need a framework to plugin third party libraries.
  • You don't want to spend lot of time on writing crud operation
  • You are not interested on adding large scale libraries into your application

Database Configuration

Documentation

Getting Started With Database Configuration

Introduction

Cygnite helps connecting with multiple databases seamlessly and running queries against database is very simple either using raw queries, Cyrus ActiveRecord ORM, and using Finders. Currently Cygnite's Cyrus ActiveRecord orm provides full supports of mysql database. Cygnite uses PDO database abstraction layer to connect with different database, meaning that you are also allowed to query against other popular databases.

Configuration

Cygnite makes configuring database connections extremely simple. The database configuration file for your application located at "src/Apps/Configs/database.php". You may define all your database connection parameters as well as which should be the default connection. Example connection configuration provided in this file. All database connections are lazy loaded by the model object.

  
 namespace Cygnite\Database;

 Configure::database(function ($config)
 {
    // set your default connection
    $config->default = 'db';

    $config->set([
        'db' => [
            'driver' => 'mysql',
            'host' => 'localhost',
            'port' => '',
            'database' => 'cygnite',
            'username' => 'root',
            'password' => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
        ]
        /*'db1' => [
            'driver' => 'mysql',
            'host' => 'localhost',
            'port' => '3607',
            'database' => 'search_engine',
            'username' => 'root',
            'password' => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
        ]*/
    ]);
 });


The above example demonstrate 'db' as default connection. You may add multiple connection configuration as db, db1, db2, db3 etc. Don't worry about the application performance, all database connections are lazy loaded by the model object. The connections are not active until you create a object of model class first time.

Retrieving Database Connection

You may access the specific connection using model object or directly extending \Cygnite\Database\ConnectionManagerTrait trait in your class.

Retrieving Connection By Model Object

Below basic model class.

  
 namespace Apps\Models;

 use Cygnite\Database\Schema;
 use Cygnite\Common\UrlManager\Url;
 use Cygnite\Database\Cyrus\ActiveRecord;

 class User extends ActiveRecord
 {
    //your database connection name
    protected $database = 'cygnite';

    //protected $tableName = 'user';

    protected $primaryKey = 'id';

    public function __construct()
    {
        parent::__construct();
    }
 }
 
 

Let us retrieve a specified database connection over model class as below.

 
 use Apps\Models\User;
 
 $user = new User();

 $connection = $user->queryBuilder()->resolveConnection(); // PDO object
 
 //or

 $connection = User::connection('cygnite'); // PDO object
 
 

You may also use "\Cygnite\Database\ConnectionManagerTrait" trait in your class to retrieve database connection as below.

 
 namespace Apps\Resources\Extensions;

 use Cygnite\Database\ConnectionManagerTrait;

 class PDOConnection 
 {
    use ConnectionManagerTrait;

   public function database($connection)
   {
      return $this->getConnection($connection);
   }
 }

 $connection = new \Apps\Resources\Extensions\PDOConnection();
 $connection->database('cygnite'); // PDO object
 
 

Testimonials

Follow Us On Facebook Twitter Google+ Linkedin
Released Under The MIT Public License. Copyrights @2012-2017. Powered by- Sanjoy Dey Productions.