Skip to content

mdabbas-cse/php-mvc-framework

Repository files navigation

php-mvc-framework

About LaraCore Framework

This is a web application framework built with PHP programming language. I believe development must be an enjoyable and creative experience to be truly fulfilling. we develop any project easily by using this framework.

NOTE: This framework is still under development in dev-mode branch.

Features and Road map

  • Simple and fast routing system.
  • Custom routing system.
  • Custom query builder.
  • Simple view template.
  • Multi layouts system.
  • HTTP helper.
  • CSRF token.
  • Develop API with api-key.
  • Component for form and input field.
  • Form validations.
  • Environment variables (Custom Dotenv).
  • Database migrations.
  • Database factories.
  • Database seeders.
  • Object relational mapping(ORM).
  • User management system.
  • Multi authentication system.
  • E-mail and SMS system.
  • Blade template (like laravel).

Requirements

  • PHP >= 7.2
  • Composer
  • MySQL
  • Apache or Nginx

Folder Structure

├── app
│   ├── Http
│   │   ├── Controllers
│   │   │   └── UserController.php
│   │   ├── Middleware
│   │   │    └── AuthMiddleware.php
│   │   └── Kernel.php
│   ├── Models
│   │   └── User.php
│   └── Providers
│       ├── AppServiceProvider.php
│       └── RouteServiceProvider.php
├── config
│   ├── app.php
│   ├── auth.php
│   ├── database.php
│   ├── mail.php
│   ├── session.php
├── database
│   ├── Factories
│   │   └── UserFactory.php
│   ├── Migrations
│   │   └── 2021_01_01_000000_create_users_table.php
│   └── Seeders
│       └── UserSeeder.php
├── resources
│   ├── assets
│   │   ├── css
│   │   │   └── style.css
│   │   └── js
│   │       └── script.js
│   ├── lang
│   │   └── en
│   │       └── validation.php
│   ├── views
│   │   ├── auth
│   │   │   ├── login.php
│   │   │   ├── register.php
│   │   │   └── reset.php
│   │   ├── layouts
│   │   │   ├── auth.php
│   │   │   └── default.php
│   │   ├── partials
│   │   │   ├── footer.php
│   │   │   ├── head.php
│   │   │   └── header.php
│   │   ├── 404.php
│   │   ├── about.php
│   │   ├── blue_print_file_view.php
│   │   └── welcome.php
├── routes
│   ├── api.php
│   └── web.php
├── storage
│   ├── cache
│   ├── logs
│   │   └── error.log
│   └── sessions
├── tests
│   └── ExampleTest.php
├── .env
├── .gitignore
├── .htaccess
├── .php-cs-fixer.php
├── composer.json
├── composer.lock
├── database.sql
├── index.php
├── laracore
├── LICENSE
├── README.md

Installation

  1. Clone the repository
git clone https://github.com/mdabbas-cse/php-mvc-framework.git
  1. Install dependencies
composer install
  1. Create a database and import the database.sql file.
  2. Configure the database connection in .env file.
DB_HOST=localhost # your database host
DB_PORT=3306 # your database port
DB_DATABASE=laracore # your database name
DB_USERNAME=root # your database username
DB_PASSWORD= # your database password
  1. Application configuration in .env file.
APP_NAME=Laracore # your application name
APP_DEBUG=true # your application debug mode
APP_URL=http://php-mvc-framework.test/ # your application url
APP_DEFAULT_LAYOUT=default # your application default layout
APP_TIME_ZONE=Asia/Dhaka # your application time zone
  1. migrate the database
php laracore migrate
  1. Run the application
php -S localhost:8000

or Your application root url

  1. Open the application in your browser http://localhost:8000
  2. Create Route in routes/web.php file
// route for home page 
Route::get('/', function () {
  return view('welcome');
});

// route for render only view any file without call back function
Route::get('/about', 'about');

// route with parameter controller and method
Route::get('/user/{id}', [UserController::class , 'show'])->middleware('auth')->name('user.show');
  1. Create User Migration or any migration in database/migrations directory or
php laracore make:migration create_users_table
  1. Edit the migration file in database/migrations directory
database/migrations/2021_01_01_000000_create_users_table.php
<?php

namespace LaraCore\Database\Migrations;

use LaraCore\Framework\Db\Migrations\Blueprint;
use LaraCore\Framework\Db\Migrations\Migration;

class User_2023_11_21_204052 extends Migration
{
  public function up()
  {
    $this->create('users', function (Blueprint $table) {
      $table->id();
      $table->string('name', 50)->nullable()->default('laracore')->comment('user name');
      $table->string('email', 25)->unique()->comment('user email');
      $table->string('password')->comment('user password');
      $table->timestamps();
    });
  }

  public function down()
  {
    $this->drop('users');
  }
}
  1. Run the migration
php laracore migrate
  1. Create User Model or any model in app/Models directory or
php laracore make:model User
  1. Edit the model file in app/Models directory
app/Models/User.php
  1. Create layout in resources/Views/layouts directory
resources/Views/layouts/default.php
  1. Create view in resources/Views directory
resources/Views/welcome.php
<?php $this->setSiteTile('Home'); ?> <!-- set site title -->

<?php $this->start('head'); ?> <!-- start head section -->

<!-- include any style sheet and script sheet -->

<?php $this->end(); ?> <!-- end head section -->

<?php $this->start('body'); ?> <!-- start body section -->

<h1>Welcome to LaraCore Framework <?= dirname(__FILE__); ?></h1>

<script>
  (function() {
    alert('hello');
  }())
</script>

<?php $this->end(); ?> <!-- end body section -->
  1. Create controller in app/Http/Controllers directory or
php laracore make:controller UserController
  1. Create model in app/Models directory or
php laracore make:model User

License

This framework is open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published