https://github.com/aaronmk44/ci4-db-backup
Ci4 Database Backup is a PHP library designed to facilitate database backups for applications built with CodeIgniter 4 and other PHP Frameworks. It's able to operate in native PHP project too. This library provides an easy way to create SQL dumps of your MySQL databases.
https://github.com/aaronmk44/ci4-db-backup
codeigniter mysql-database php-framework php-library
Last synced: 3 months ago
JSON representation
Ci4 Database Backup is a PHP library designed to facilitate database backups for applications built with CodeIgniter 4 and other PHP Frameworks. It's able to operate in native PHP project too. This library provides an easy way to create SQL dumps of your MySQL databases.
- Host: GitHub
- URL: https://github.com/aaronmk44/ci4-db-backup
- Owner: AaronMk44
- Created: 2024-06-06T13:58:22.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-06-13T12:47:16.000Z (11 months ago)
- Last Synced: 2025-01-31T22:11:40.221Z (3 months ago)
- Topics: codeigniter, mysql-database, php-framework, php-library
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ci4 Database Backup

## Overview
Ci4 Database Backup is a PHP library designed to facilitate database backups for applications built with CodeIgniter 4 and other PHP Frameworks. It's able to operate in native PHP project too. This library provides an easy way to create SQL dumps of your MySQL databases.
## Features
- Simple and easy to use
- Generates SQL dumps of your database
- Supports CodeIgniter 4## Installation
You can install this library via Composer. Run the following command:
```sh
composer require aaronmk44/ci4-db-backup
```## Usage
Here is an example of how to use the `Ci4 Database Backup` library:
### Basic Usage
1. **Include Autoload File**: Ensure you include the Composer autoload file in your script.
2. **Create a Backup Script**:
```php
'localhost',
'username' => 'root',
'password' => ''
]))->backup('test_db', 'path/to/backups');
```In this example:
- The `Ci4DbBackup` class is instantiated with database connection details (host, username, and password).
- The `backup` method is called with the database name (`test_db`) and the path where the backup file should be saved.### Advanced Usage
For more advanced usage and options, refer to the documentation.
## Methods
### `__construct`
Initializes the `Ci4DbBackup` class with database connection details.
```php
public function __construct(array $dbConfig)
```- **$dbConfig**: An associative array with the following keys:
- `host`: Database host (e.g., `localhost`)
- `username`: Database username
- `password`: Database password### `backup`
Creates a backup of the specified database.
```php
public function backup(string $database, string $backupPath)
```- **$database**: The name of the database to back up
- **$backupPath**: The path where the backup file will be saved## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your improvements.
## Author
- **Aaron Mkandawire** - [AaronMk44](https://github.com/AaronMk44)
## Acknowledgements
https://dev.to/joemoses33/create-a-composer-package-how-to-29kn