bibo/mvc

Simple MVC framework

dev-main 2024-07-17 20:57 UTC

This package is auto-updated.

Last update: 2024-10-05 01:00:50 UTC


README

Easy and simple for usage

Installation

git clone https://github.com/biboletin/mvc.git
cd /path/to/project
composer update
copy/paste/rename config.sample.php to config.php
cd /path/to/project/public

Variant 1
Use php built-in server

php -S localhost:8000

Variant 2
Create virtual host and go to

http://hostname

Create/Configure Migrations

Examples:

  • Create migrations in Database/Migrations
    Users.php:
use Illuminate\Database\Capsule\Manager as Capsule;

Capsule::schema()->create('users', function ($table) {
    $table->increments('id');
    $table->string('name');
    $table->string('email')->unique();
    $table->string('password');
    $table->timestamps();
});
  • Create Users Model in App/Models
    Users.php
namespace App\Models;

use Illuminate\Database\Eloquent\Model as Eloquent;

class Users extends Eloquent
{
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    protected $hidden = [
        'name',
        'email',
        'password',
    ];
}
  • If not exist create install.php in public directory, else edit it:
include_once __DIR__ . '/../vendor/autoload.php';
include_once __DIR__ . '/../bootstrap.php';
include_once __DIR__ . '/../Database/Migrations/Users.php';

use App\Models\Users;
use Core\Config;

Users::Create([
    'name' => 'username',
    'email' => 'name@example.com',
    'password' => password_hash('password', Config::get('security.algorithm'), [
        'cost' => Config::get('security.cost')
        ]),
]);

Now go to http://site-name/install.php

Notes

Works without hardcoded routes.

Important!

Use https!

        /**
         * Set base url
         * Change to https for better use
         */
        'url' => 'https://localhost/',

For proper loading javascript and css.

Create if not exists mvc/tmp/sessions

License

MIT