avoutic / web-framework-mysql
MySQL module for WebFramework
Installs: 1 057
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/avoutic/web-framework-mysql
Requires
- ext-mysqli: *
- avoutic/web-framework: ^11
Requires (Dev)
README
This module provides MySQL and MariaDB database integration for WebFramework.
Installation
Install via Composer:
composer require avoutic/web-framework-mysql
Make sure the definitions file is included in your project by adding it to definition_files in your config.php file:
return [ 'definition_files' => [ '../vendor/avoutic/web-framework/definitions/definitions.php', '../vendor/avoutic/web-framework-mysql/definitions/definitions.php', 'app_definitions.php', ], ];
Requirements
- PHP 8.2 or higher
- MySQL or MariaDB server
- PHP mysqli extension
- WebFramework core package (^11)
Usage
The module provides MySQL integration for WebFramework, enabling database access. It implements the WebFramework Database interface to access the database.
To use MySQL for database access you need to add it in your PHP-DI definitions:
return [ Database::class => DI\autowire(MysqliDatabase::class), ];
Configuration
If you are using the definition from definitions/defitinions.php. You can just add the following db_config.main.php to your auth config directory (config/auth):
<?php return [ 'database_host' => env('DATABASE_HOST', 'localhost'), 'database_user' => env('DATABASE_USER', 'your_user'), 'database_password' => env('DATABASE_PASSWORD', 'your_password'), 'database_database' => env('DATABASE_DATABASE', 'your_database') ]
License
MIT License - see LICENSE file for details.