All Posts

Create Your Own Backend API With PHP Part 7

Entities and permissions The whole point of this framework is to make it easy to create entities and write custom modules easily. So we can create an entity with a few lines of code, we should consider the framework successful. Let’s create an entity for Blog Posts as an example. Create a folder under the modules directory: cd modules mkdir blog Now create blog.php and entity.fields.json files under the blog directory.

Create Your Own Backend API With PHP Part 6

Authentication and Authorization We use The PHP League’s Oauth 2.0 (https://oauth2.thephpleague.com/) server for the authentication. First of all we need to add our own module named oauth under the module directory and install the package via composer composer require league/oauth2-server If you look at our router, you will see that an authentication request is separately considered, unlike the routing.json file scan for each module to find the acting module. Therefore the endpoints that we will create in oauth module’s routing.

Create Your Own Backend API With PHP Part 5

Entities Entities are crucial parts of backend APIs. A developer should be able to easily create an entity with a configuration file. An example can be as follows: entity.fields.json { "fields": [ { "name": "name", "type": "string", "options" : { "length": 255, "notNull": false } }, { "name": "surname", "type": "string", "options" : { "length": 255, "notNull": false } }, { "name": "password", "type": "string", "options" : { "length": 255, "notNull": false } }, { "name": "email", "type": "string", "options": { "unique": true } }, { "name": "created_at", "type": "integer" }, { "name": "updated_at", "type": "integer" }, { "name": "active", "type": "boolean" } ] } After adding this to a custom module, the system should recognize this as an entity and automatically behave as one.

Create Your Own Backend API With PHP Part 4

Database connection There should be only a single db connection each time there is a request. This is why we load the global environmental variables at the beginning of the script, use the db credentials to connect to the database only a single time. If you visit global.php you will see $global_connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams); This connection variable later used in the database.php under modules, public function __construct(){ global $global_connection; $this->connection = $global_connection; } Database object later is called on every time the system object is called.

Create Your Own Backend API With PHP Part 3

Routing We have decided to use this framework for 2 purposes, first for terminal usage, second is to generate endpoints for REST. Terminal usage Sometimes all I need is to run a piece of code to do a simple job for my daily usage. For example I want to access a remote blog daily, read it, check for certain phrases and store the result (whatever result I want) into the database.

Create Your Own Backend API With PHP Part 2

Main structure and the technology As I discussed in the previous post, one of the most important parts is to keep the syntax as simple as possible for a newbie to be able to jump on right away. We also should avoid using any sort of fancy tools which would basically complicate the development process. We also should use most popular tools which have proved themselves and supported by a strong community.

Create Your Own Backend API With PHP Part 1

Motivation In software development, most of the time what you need is a small piece of code to run. If you are working with a framework, it becomes very heavy to do simple tasks in shorter times. That’s why I decided to write my own framework for my daily tasks. To write or to not to write There are hundreds of frameworks out there, of course it is very unnecessary to write your own framework!

Raspberry Pi Zero security camera

Raspberry Pi Zero security camera

Download files Get the files from Github What are the main features? I have built a security camera using a Raspberry Pi Zero, built the case with camera mount, easy to mount to a wall. Designed using OpenSCAD, so it’s fully parametric. The main feature of this security camera is that it captures the movements and emails them to you, but first it checks if you are at home by trying to connect to your phone via bluetooth.

The future of business, Robotics Agencies

The future of business, Robotics Agencies

The robotics revolution is about to happen as we are all expecting. But how will it take place, and what will change in our lives? The robot Open-source is the only way Like everything else in life, the development will be gradual so that it won’t happen overnight. It is essential for the giant companies to get involved in the robotics development. Still, I don’t think that it will be them who will take the initiative, it will be crowdfunded open-source communities, because there won’t be big wins for early starting commercial organizations.

Evolution Simulation

Evolution Simulation

Here is the link http://www.beyazcuce.com/hunt Introduction I have always wondered if evolution can be simulated or not and decided to try by myself. Even though I truly believe that the evolution does exist and work in the everyday life, seeing soemthing with your own eyes makes you feel it to your bones, just like seeing a planet by a telescope for the first time. You know that it is there, but when you see it with your own eyes, you experience a special moment.