Inspiring You The Next - A Product Of UROSD Lab

Installs: 147

Dependents: 0

Suggesters: 0

Security: 0

Stars: 10

Watchers: 2

Forks: 5

Open Issues: 0



v1.0.0 2017-05-26 19:30 UTC

This package is not auto-updated.

Last update: 2020-09-18 21:07:30 UTC


📢 Let's build together by not reinventing the wheel but assembling the wheels to reinvent a new 🚀

🔰 Version 1.0.0

🐾 Installation

🔹 First install composer globally(if you don't have it) by running the following commands
For Ubuntu

 curl -sS | php && sudo mv composer.phar /usr/local/bin/composer

For Cent OS

 curl -sS | php && chmod +x composer.phar && sudo mv composer.phar /usr/local/bin/composer

🔹 Then install Elham by the following command(for latest stable releases)

 composer create-project chandan07cse/elham YOUR_PROJECT_NAME

🔹 But if you want Elham from its master branch, then you could certainly type it

 composer create-project chandan07cse/elham=dev-master YOUR_PROJECT_NAME

🔹 Now cd into your_project_name/public & run by the php command

 php -S localhost:8000

🔹 Note : For the rest of the project we'll run each & every command from the project directory. For that

 cd ../

📦 Dependencies

🔹 To check the list of dependencies Elham relies, run the command

 composer info

🔦 Visual Dependencies

🎹 Elham Command Alias

🔹 Let's run the below command to run elham command if you are in Linux

 echo "alias elham='./elham'" >> ~/.bash_aliases && source ~/.bash_aliases

🔹 But if you are in windows machine add the executibles in your path. If you are using Laragon then it can be


🔹 Now you can run elham command through out your project. To check run from the terminal if you are in linux enviornment


🔹 But if you are in windows, then

 php elham

🎻 Build Controller Through CLI

🔹 Elham provides you the build:controller command

 elham build:controller YourController

🔹 Check it by finding it in app/Controller directory of your project.

🔹 By default elham generates resourceful controller. But if you want you can always make a plain controller by running

 elham build:controller YourController plain

🎸 Build Model Through CLI

🔹 Elham also provides you build:model command

 elham build:model YourModel

🔹 It'll create a model with necessary properties & methods based on your database table.

🎷 Build Form Through CLI

🔹 Elham ships with build:form command

 elham build:form YourForm

🔹 A dummy blade form will be generated inside app/Views/_partials directory.

🎼 Build Validator Through CLI

🔹 Elham also provides you build:validator command

 elham build:validator YourValidator

🔹 A validation class will be generated inside app/Validation directory.

🎤 Help keyword for CLI generators

🔹 Now if you need any help just type

 elham help build:keyword

🔹 All the commands check the existing ones as well for simplicity.

👔 👗 Elham Templating Engines

🔹 Elham ships with Blade and Plain view for rendering its View. But if you want you can use twig too. For that you will need to install TWIG by the following command

 composer require twig/twig

🌴 🌱 Elham Migrations & Seeding

🔹 As Elham used Phinx for migrations & seeding, so to use phinx command just run from the terminal

 echo "alias phinx='./phinx'" >> ~/.bash_aliases && source ~/.bash_aliases

🔹 Now you'll be able to run phinx command. To make sure phinx running correctly, run in terminal


🔹 You'll get the list of Phinx command. To use phinx, first initialize it by the following command

 phinx init

🔹 A phinx.yml file will be generated. You need to customize it. Sample customization for development listed below

 default_database: development
          adapter: sqlite
          host: localhost
          name: db/database.sqlite
          user: root
          pass: ''
          port: 3306
          charset: utf8

🔹 Phinx uses 🐫 CamelCase for its functioning & it'll store the migrations & seeding inside db/migration & db/seeds directory respectively. So if you wanna create a migration for Students table, just run in terminal

 phinx create Students

🔹 A new unique migration for Students will be generated inside db/migrations directory of Elham like below

 use Phinx\Migration\AbstractMigration;
 class Students extends AbstractMigration
       public function change()


🔹 Now we not gonna use the change method for the migration. Beside we'll create two methods up() & down() for our migration & rollback. So for that we gonna code a bit something like below. Say we've our student table consisting with roll & name.

 use Phinx\Migration\AbstractMigration;
 class Students extends AbstractMigration
       public function up()
            $students = $this->table('students');
       public function down()


🔹 Now to migrate, run from terminal

   phinx migrate

🔹 It'll affect our default db/databse.sqlite hopefully. Now to rollback, just run from terminal

 phinx rollback

🔹 To explore more about Phinx, please read the 🔗documentation.

🔹 Now for seeding, we just need to create the seeder class from the cli. Say, we need to create a UserSeeder to seed some datumn into users table. To create the UserSeeder class

 phinx seed:create UserSeeder

🔹 We'll get the UserSeeder class inside db/seeds directory. Inside there, we'll get

 use Phinx\Seed\AbstractSeed;
 class UserSeeder extends AbstractSeed
    public function run()


🔹 Actually we can seed in ✌️ ways.

1️⃣ Manual Seeding

2️⃣ Faker Seeding

🔹 For Manual Seeding we can write something like this in UserSeeder class

 use Phinx\Seed\AbstractSeed;
 class UserSeeder extends AbstractSeed
    public function run()
      $data = array(
              'username'    => 'chandan07cse',
              'password' => md5('me'),
              'email' => '',
              'image' => 'public/images/chandan07cse.jpg',
              'activation_code' => md5(rand(0,1000)),
              'active' => 1
              'username'    => 'mamun10pgd',
              'password' => md5('mamun10pgd@!'),
              'email' => '',
              'image' => 'public/images/mamun10pgd.jpg',
              'activation_code' => md5(rand(0,1000)),
              'active' => 0

       $this->insert('users', $data);

🔹 Now run from terminal

phinx seed:run

🔹 If you wanna run a specific class then run

phinx seed:run -s UserSeeder

🔹 For faker seeding, we can write something like this in UserSeeder class

use Phinx\Seed\AbstractSeed;
class UserSeeder extends AbstractSeed
   public function run()
     $faker = Faker\Factory::create();
     $data = [];
     for ($i = 0; $i < 4; $i++) {
         $data[] = [

             'username'      => $faker->userName,
             'password'      => md5($faker->password),
             'email'      => $faker->email,
             'image'      => $faker->image($dir = 'public/images',$width = 640, $height = 480),
             'activation_code'=> $faker->randomElement(),
             'active'      => $faker->boolean


     $this->insert('users', $data);


⚽🏀🏈⚾🎾 Elham Playground

🔹 Elham also uses Psyshell for tinkering with its functionalities, so to use psysh command just run from the terminal

 echo "alias psysh='./psysh'" >> ~/.bash_aliases && source ~/.bash_aliases

🔹 Now if you wanna tinkering with psyshell just run in terminal


🔹 You'll be into the Psyshell now. If you wanna start toying around then first initialize the proper environment. To init the environment, run in terminal

 $environment = new Dotenv\Dotenv(__DIR__);

🔹 To init the database with eloquent, run in terminal

 $db = new config\Database;

🔹 Now if you wanna query through Eloquent/Query Builder, create an instance of the Capsule


🔹 Now if you wanna play with User model, create an object of User by running in terminal

 $user = new Elham\Model\User;

🔹 To get all data from User model, just run in terminal


🔹 And if you wanna query through PDO, create an instance of the PDO

 $pdo = $db->pdo();

🔹 If you wanna insert some data into users table using pdo, do the following

  $pdo =  $pdo->prepare("insert into users values(:id,:username,:email,:password,:image,:activation_code,:active)");

🔹 You can run every bit of eloquent & pdo queries along with other functionalities through Psyshell.

📲 Elham API Call

🔹 Elham uses Unirest libraries for its api calling. Its pretty easy to call an api using the Elham's api method like below

        $uri = '';
        $content_type = 'application/json';
        $request_parameter = ['foo' => 'hello', 'bar' => 'world'];
        $request_type = 'post';
        $api_response = $this->api($uri,$content_type,$request_parameter,$request_type);

🔍 Elham Vulnerability Scan

🔹 To check any vulnerable package issue in Elham, just run the following command

 elham check:vulnerability

🏡 Elham Frontend Housekeeping

🔹 Elham uses Gulp for basic front-end housekeeping of tasks like minifying css,js, autoprefixing of css and so on & so forth. To use gulp, first install node js by the following command

 sudo apt-get install npm

🔹 After that we need to install gulp globaly by the following command in ubuntu.

 sudo npm install -g gulp

🔹 But if you are in windows then in Laragon terminal type

  npm install -g gulp

🔹 As pacakge.json already ships with Elham. So you don't have to create it. To install gulp just run the following command

 sudo npm install gulp --save-dev

🔹 But if you are in windows, then run

 npm install gulp --save-dev

🔹 The way Gulp work is - Everything is split into various plugins. So each plugin does one job & one job only. And that way we can pipe the output of one function to another. So we can say - Let's autoprefix this file & then minify it & then output it some file & then finally provide some sort of notifications. All of that stuff is really easy with Gulp.

🔹 So if we want to use plugins, we need to install some. Lets install, just to get started, How about minifying our css We can do that by running into ubuntu terminal

 sudo npm install gulp-clean-css --save-dev

🔹 For windows run

 npm install gulp-clean-css --save-dev

🔹 Now if you wanna minifying the js then in ubuntu terminal

sudo npm install gulp-jsmin --save-dev

🔹 But if you are in windows then run in Laragon terminal

 npm install gulp-jsmin --save-dev

🔹 To use gulp, run from terminal


🍓 Elham Zero Second Deployment

🔹 Elham proudly compatibles with ngrok. So you can deploy it less than a second. For that you'll have to install node & nodejs-legacy by the following command

 sudo apt-get install node
 sudo apt install nodejs-legacy

🔹 After that we gonna install ngrok through (npm)node package manager globally

 sudo npm install ngrok -g

🔹 Now we gonna deploy our project by just running the following command

 ngrok http 8000

🔹 Make sure you are running your project through port 8000. If you are using other port, then use that port to ngrok

🍇 Elham Production Deployment

🔹 Don't worry it also supports any repo(Github,Gitlab,Bitbucket....) and any CI (Jenkins) and any server(Linux Distro. preferred) in deployment.