Nasrul Hazim Bin Mohamad



Year 2016, InsyaAllah, next year to be a year of sharing knowledge of what I’ve learnt so far. Following are the trainings I would like to conduct:

1. Mobile Apps Development with jQuery Mobile
2. Mobile Apps Development with Intel XDK (incoming)
3. API Development with Slim Framework (incoming)
4. PHP Basic / Advanced
5. Web Development with CakePHP 3 (incoming)
6. Web Development with Laravel 5 (incoming)
7. Web Development with Yii Framework 2 (incoming)
8. WordPress for Developers – Beginner Level
9. WordPress Theme Development
10. WordPress Plugin Development

Those status incoming, it’s the one I’m preparing the syllabus & materials, summarizing the process, and so on. Hope more things can be share other than mentioned above such as the tools I’ve used along the process of the development – Sublime Text 3, SQLYog, Putty, Git and so on

Quick Development: Slim Framework + Illuminate(Laravel)


Create a project folder and add a composer.json file in it and paste the following codes, and run composer install. You should have Slim Framework, Twig, Illuminate(Laravel) in the project folder.

    "name": "Quick Dev!",
    "require": {
        "php": ">=5.3.0",
        "slim/slim": "2.*",
        "slim/extras": "2.*",
        "twig/twig": "1.*",
        "illuminate/database": "*"
    "autoload": {
        "classmap": [

Add a index.php file in project folder and copy paste the following:


require 'vendor/autoload.php';

// Database information
$settings = array(
    'driver' => 'mysql',
    'host' => '',
    'database' => 'dbname',
    'username' => 'username',
    'password' => 'password',
    'collation' => 'utf8_general_ci',
    'prefix' => '',
    'charset' => 'utf8'

// Bootstrap Eloquent ORM
$container = new IlluminateContainerContainer;
$connFactory = new IlluminateDatabaseConnectorsConnectionFactory($container);
$conn = $connFactory->make($settings);
$resolver = new IlluminateDatabaseConnectionResolver();
$resolver->addConnection('default', $conn);

$app = new SlimSlim();

$app->get('/', function () {
    echo "<h1>Quick Dev!!</h1>";
    $articles = Article::all();
    echo $articles->toJson();


Create a folder named models in the project folder and add the following into a file named Article.php:


class Article extends IlluminateDatabaseEloquentModel


Don’t forget our .htaccess file in a project folder. 🙂

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Now you can navigate to your system, for example: http://localhost/quick-dev

p/s: You can use Twig later on. 🙂


Micro-framework: Slim


Setting up Slim Application

  • Create a folder for your project, mine called slim
  • create a composer.json in the directory and open up your Command Prompt / Terminal and run composer install. Later you should have something similar to Screenshot #2.

    Screenshot #1


    Screenshot #2

Setting up RedBeanPHP4

  • Download RedbeanPHP4
  • Create a folder named RedBeanPHP4 in vendor directory and extract download zip file above and copy the rb.php into slim/vendor/RedBeanPHP4 – see Screenshot #2.
  • Include the rb.php in slim/vendor/autoloader.php
  • Then, add MySQL connection settings.

Let’s start it!

  • Create a index.php in slim directory and add the following:
    mf-slimframeworkBasically what’s in this index.php is to add new user and view a user details.
  • You may need to create new database, then new table named users. I used the following fields – id, name, email, created and modified
  • Next, when the database and tables created, you may run http://localhost/slim/users/add/Nasrul Hazim/ and you may want to add more records. Suppose each time new user created, you will be redirected to the view user info page – http://localhost/slim/users/view/1 and see the next screenshot – I only var_dump the user details and you want to add some nice view or probably pass a JSON encoding.