Download the PHP package migro/php-core-migration without Composer
On this page you can find all versions of the php package migro/php-core-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download migro/php-core-migration
More information about migro/php-core-migration
Files in migro/php-core-migration
Package php-core-migration
Short Description A PHP library providing a code-first approach for database migrations. Designed for simplicity and ease of use, it allows developers to define and manage database schema changes directly in code.
License MIT
Informations about the package php-core-migration
Code-First Approach into Core PHP
Description
This repository contains examples and best practices for using a code-first approach in Core PHP. It is intended for developers who are looking to understand and implement this methodology in their PHP projects.
Table of Contents
- Installation
- Usage
- Contributing
Installation
To install and run this project, you need to have PHP and MySQL installed on your machine.
- Clone this repository.
- Navigate to the project directory.
- Update the
config.php
file with your database credentials.
The config.php
file should look like this:
Usage
To connect to the database, you need to call the connectToDatabase
function from the connection.php
file. Here's how the connection.php
file looks:
To create a table in the database, you can use the createTable
function from the BaseMigration
class in the migration
folder. Here's how the BaseMigration
class looks:
The BaseMigration
class is extended by other classes to create specific tables. For example, the RoleMigration
class creates a tbl_userRoles
table if it doesn't exist. Here's how the RoleMigration
class looks:
After setting up the database connection and defining your migration classes, you need to execute the migrations to create the tables in your database. This is done in the Migrate.php
file. Here's how the Migrate.php
file looks:
Alternatively, if you have a local server environment set up (like XAMPP, WAMP, or MAMP), you can also navigate to the Migrate.php
file through your web browser by typing the local server URL followed by the path to the Migrate.php
file. For example:
if your table will not be exist that will be created
for further guidance just visit my article https://getsmartsolution.com/code-first-approach-into-core-php/
Contributing
Currently, this project only supports creating tables. I am working on developing a full-fledged migration system for Core PHP. If you have any ideas or improvements, feel free to make a pull request.