devmboo / monolog
A simple and efficient web application framework for rapid development.
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
pkg:composer/devmboo/monolog
Requires
- php: >=8.0
- phpmailer/phpmailer: ^6.9
This package is auto-updated.
Last update: 2025-12-18 17:19:29 UTC
README
Welcome to Monolog, a custom PHP framework for building modern and dynamic web applications. This framework is designed to be simple, flexible, and efficient for both small and large projects.
π οΈ Framework Overview
Monolog is a PHP framework that streamlines the development process by providing easy-to-use CLI commands, project scaffolding, and environment configurations. It helps you quickly build out essential features like controllers, models, migrations, views, and more.
It was built using PHP 8.3.x and relies on Composer for dependency management.
ποΈ Project Structure
Here's a breakdown of the directory structure in the Monolog project:
-
/src: Contains the main source files for the framework./app: Core application files./config: Configuration files (e.g.,stacking.php)./console/commands: Holds all the custom CLI commands.MakeComponent.phpMakeController.phpMakeLayout.phpMakeMigrate.phpMakeMiddleware.phpMakeMigration.phpMakeModel.phpMakeSeeder.phpMakeView.phpServerCommand.php
/controller: Contains controller files.Controller.php
/helpers: Helper files for different purposes./common: Common helpers likeenv.php./database: Helpers related to database, e.g.,Migration.php./environment: Environment helpers likeEnv.php.
/http: HTTP-related files such as requests and responses.Request.phpResponse.phpRouter.php
/middlewares: Middleware files for API and Web./api: API-related middlewares.EnsureApplicationJWT.php
/web: Web-related middlewares.EnsureApplicationActive.phpEnsureApplicationCrsfToken.phpEnsureAutenticateSessionUser.php
/resources: Resource files like views and components.Component.phpView.php/views: Views of the application.public.html
/database: Database-related files.Database.php/migrations: Migration files for the database schema.2025_03_04_01_52_03_create_migrations_table.php
/seeders: Database seeding files.
/model: Contains model files.Model.php
/router: Contains routing files.web.php
/view: Stores view files for the application./public: Public assets like CSS, images, and JS./css/ico/images/js
/resources: Stores additional resource files./views: Stores view files.app.html/components: Individual components likebanner.html./pages: Static page views likehome.html.
-
/vendor: Composer dependencies and autoload files.autoload.php/composer: Composer-specific files.autoload_classmap.phpautoload_namespaces.phpautoload_psr4.phpautoload_real.phpautoload_static.phpClassLoader.phpinstalled.jsoninstalled.phpInstalledVersions.phpLICENSEplatform_check.php
-
/resources: Stores resources like layouts, static views, and the environment file (.env). -
/node_modules: Contains the installed NPM packages for front-end development, including Tailwind CSS.
π Features
- Custom CLI commands: Automate repetitive tasks such as creating controllers, models, migrations, views, etc.
- Simple and clean structure: Based on the MVC pattern to promote scalability and maintainability.
- Environment configuration: Using
.envfiles to manage environment variables for different environments (e.g., development, production). - Tailwind CSS Integration: Easily configure Tailwind for front-end styling.
βοΈ Installation & Setup
To get started with Monolog, follow these steps:
1. Install project CLI
composer require devmboo/monolog
2. Navigate to the project directory
cd your-project-directory
3. Install dependencies using Composer
Ensure that you have Composer installed. If you don't have it, you can install it by following the instructions on the official website.
composer install
This will install all the required dependencies for the project.
4. Install front-end dependencies (Tailwind CSS)
Monolog uses Tailwind CSS for styling. To install the required NPM packages, run the following:
npm install
This will install Tailwind and other necessary front-end dependencies.
5. Configure the .env file
Rename the .env.example file to .env and fill in the necessary configuration details:
#### APPLICATION ####
APP_KEY=
APP_LOCAL=homolog
APP_URL=http://localhost
APP_NAME=monolog
APP_PORT=8000
#### DATABASE ####
DB_DRIVER=YOUR_DRIVER
DB_HOST=YOUR_HOST
DB_NAME=YOUR_DB_NAME
DB_USER=YOUR_USER
DB_PASSWORD=YOUR_PASSWORD
DB_PORT=YOUR_PORT
#### SUPPORT MODE ####
STANDARD_MODE=false
#### ENCRYPTY KEY ####
ENCRYPT=
#### MAILER SETTINGS ####
MAIL_DRIVER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=your_email@example.com
MAIL_PASSWORD=your_email_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=no-reply@example.com
MAIL_FROM_NAME="Monolog System"
6. Build the front-end assets
Once NPM packages are installed, you can build the front-end assets by running:
npm run dev
This will compile your assets, including Tailwind CSS, and make them ready for use.
7. Start the development server
Use the following command to start the server:
php mono.php server
This command will launch the built-in PHP server using the port defined in your .env file. By default, it uses port 8000.
8. Create layouts and other components
You can create layouts, controllers, models, migrations, and other components using the following commands:
- Create a new layout:
php mono.php make:layout <layout-name>
- Create a new controller:
php mono.php make:controller <controller-name>
- Create a new model:
php mono.php make:model <model-name>
- Create a new migration:
php mono.php make:migration <migration-name>
- Create a new view:
php mono.php make:view <view-name>
- Create a new seeder:
php mono.php make:seeder <seeder-name>
π How to Code
- Controllers: Store your controllers in the
/src/app/controllersdirectory. You can generate them using themake:controllercommand. - Models: Create models in
/src/app/models. Use themake:modelcommand for automatic generation. - Migrations: Define your database structure using migrations. Generate them with
make:migration. - Views: All views are stored in
/resources/views. You can create views withmake:viewor create layouts that are used globally. - Layouts: Use layouts for structuring the HTML template of your application. These can be created using the
make:layoutcommand.
You can easily extend and modify any part of this framework to meet your project's needs.
π§ Available CLI Commands
Hereβs a list of the available commands:
| Command | Description |
|---|---|
php mono.php server |
Starts the built-in PHP server. |
php mono.php standard |
Disables the application. |
php mono.php make:controller <name> |
Creates a new controller. |
php mono.php make:model <name> |
Creates a new model. |
php mono.php make:migration <name> |
Creates a new migration file. |
php mono.php make:middleware <name> |
Creates a new middleware file. |
php mono.php make:seeder <name> |
Creates a new seeder. |
php mono.php make:view <name> |
Creates a new view file. |
php mono.php make:layout <name> |
Creates a new layout template. |
php mono.php make:component <name> |
Creates a new component file. |
php mono.php make:mail <name> |
Creates a new mail layout file template. |
php mono.php make:seed |
Executes all seeder classes to insert initial data into the database. |
php mono.php make:migrate |
Executes all pending migrations in the database. |
π License
This project is open source and available under the MIT License.
π Documentation Summary
| Method | Description |
|---|---|
handle() |
Orchestrates the application's initialization, including environment loading, request capturing, and route dispatching. |
Monolog - Basic CRUD Example
Introduction
This document provides a basic implementation of a CRUD (Create, Read, Update, Delete) system for a User model using the Model class. The User model extends Model, leveraging its built-in database methods.
Prerequisites
- PHP 8+
- PDO Extension enabled
- A properly configured database connection
User Model Implementation
Create a User model that extends Model use cli php mono.php make:model :
class User extends Model { protected string $tbname = 'users'; }
CRUD Operations
1. Create a User
$user = new User(); $created = $user->create([ 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'password' => password_hash('secret', PASSWORD_BCRYPT) ]); if ($created) { echo "User created successfully!"; }
2. Retrieve All Users
$user = new User(); $users = $user->all(); print_r($users);
3. Find a User by ID
$user = new User(); $foundUser = $user->find(1); print_r($foundUser);
4. Update a User
$user = new User(); $updated = $user->update(1, [ 'name' => 'John Updated', 'email' => 'john.updated@example.com' ]); if ($updated) { echo "User updated successfully!"; }
5. Delete a User
$user = new User(); $deleted = $user->delete(1); if ($deleted) { echo "User deleted successfully!"; }
Conclusion
This example demonstrates how to implement a basic CRUD system using the Model class. You can extend this functionality by adding additional methods and refining validations.
/**
- Monolog PHP Framework.
- Version 1.0 (2025).
- Monolog is a fresh take on project structure, inspired by Laravel and CodeIgniter 4.
- It aims to provide a clean, efficient, and developer-friendly architecture.
- @see https://github.com/devMboo/monolog The Monolog GitHub repository
- @author Luan Chaves
- @copyright 2025 Luan Chaves
- @license https://opensource.org/licenses/MIT MIT License
- @note This framework is distributed in the hope that it will be useful,
-
but WITHOUT ANY WARRANTY; without even the implied warranty of -
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
π¬ Questions?
Feel free to open an issue or ask questions through our discussion board. Happy coding! π