Creating my First PHP Framework : Day 1

Why ? 

So why should you write your own framework? Firstly, it is a great learning experience. You will get to learn PHP inside-out. You will get to learn object-oriented programming, design patterns and considerations.


More importantly, you have complete control over your framework. Your ideas can be built right into your framework. Although always not beneficial, you can write coding conventions/functions/modules the way you like.


11 Months ago i started building MVC Php framework ,  the idea was create a simple flixible framework  which any developer can use it without problem

ORM

The ORM  is a kind of abstraction of database , it avoids you to to write long SQL statmemnts using 
functions eg save to INSERT data or to find  to SELECT data

use Cake\ORM\TableRegistry;

$data = [
    'title' => 'My first article',
    'body' => 'It is a great article',
    'user_id' => 1,
    'tags' => [
        '_ids' => [1, 2, 3]
    ],
    'comments' => [
        ['comment' => 'Good job'],
        ['comment' => 'Awesome work'],
    ]
];

$articles = TableRegistry::get('Articles');
$article = $articles->newEntity($data, [
    'associated' => ['Tags', 'Comments']
]);
$articles->save($article, [
    'associated' => ['Tags', 'Comments']
])



For my project I wanted to use an open source ORM , since I prefer I use cakephp his orm available on github ORM

composer require "cakephp/orm": "^3.1"










Comments

Popular posts from this blog

Twitter API with PHP

Realtime Chat Application with CakePHP and Socket.IO #1

Let's build a mobile application with Ionic Framework #3