DEV Community

Cover image for High speed-dev: A minute to be up & running
neoan
neoan

Posted on

High speed-dev: A minute to be up & running

No, it doesn't run on PHP 7.2!

The neoan-core Lenkrad doesn't play the compatibility game. Being backward compatible to older PHP versions or playing nicely with a plethora of ecosystems is a challenge that not only slows down development, but results in verbose usage and unoptimized core code.

I wanted to have a framework for the next generation. I wanted to finally have a framework that let's me write business logic the way I want it to behave.

Let's compare:

In Laravel, I need a migration and a model to make the Eloquent ORM work:

the migration


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{

    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('password');
            $table->string('email')->unique();
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::drop('users');
    }
};


Enter fullscreen mode Exit fullscreen mode

And the model

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{

    protected $table = 'users';
}
Enter fullscreen mode Exit fullscreen mode

We might be used to this, but what we really want to write is:


class User extends Model
{
   #[IsPrimaryKey]
   public readonly int $id;
   public string $name;

   #[Transform(Hash::class)]
   public string $password;

   #[IsUnique]
   public string $email;

   use Timestamps;
}

Enter fullscreen mode Exit fullscreen mode

The advantage is not only easier reference and less verbose code. Your IDE will be able to better help you with navigating objects through auto-completion:

$user = new User();
$user->name = 'Adam'; // name was suggested, as it's a property of the model class
...

Enter fullscreen mode Exit fullscreen mode

Interested?

If you have PHP8.1 and interested in seeing how a framework could actually make your life easier, try it out:

composer create-project neoan.io/starter-project [my-app]

The package is light in dependencies and up & running in seconds. Feedback highly appreciated!

Top comments (0)