This document provides a guide for developers who want to contribute to the CodeIgniter to Laravel Migration Tool.
The project follows a standard Laravel structure, with the core logic located in the app directory.
app/
βββ Console/
β βββ Commands/
β βββ MigrateCodeIgniterApp.php # The main Artisan command that kicks off the migration.
βββ Contracts/
β βββ CIAnalyzerInterface.php # Contract for analyzing a CodeIgniter project.
β βββ CIConverterInterface.php # Contract for converting CodeIgniter components to Laravel.
β βββ CIMigrationCoordinatorInterface.php # Contract for coordinating the entire migration process.
β βββ NodeProcessorInterface.php # Contract for processing individual PHP parser nodes.
βββ Enums/
β βββ CIVersion.php # Enum for CodeIgniter versions.
β βββ LaravelDatabaseDriver.php # Enum for Laravel database drivers.
βββ Factories/
β βββ CIConfigProcessorFactory.php
β βββ CIControllerProcessorFactory.php
β βββ CIDatabaseProcessorFactory.php
β βββ CIModelProcessorFactory.php
β βββ CIRouteProcessorFactory.php
βββ Http/
β βββ ... # Standard Laravel HTTP kernel.
βββ Models/
β βββ ... # Standard Laravel models.
βββ Providers/
β βββ AppServiceProvider.php
β βββ ConverterServiceProvider.php # Binds the analyzer and converter implementations.
βββ Services/
β βββ FileHandlerService.php # Handles file system operations.
β βββ LaravelProjectService.php # Manages the creation and modification of the new Laravel project.
β βββ LaravelProjectSetupService.php # Sets up a new Laravel project.
β βββ LogService.php # Handles logging.
β βββ PromptService.php # Handles user prompts.
β βββ StatusBarService.php # Manages the progress bar display.
β βββ Abstracts/
β β βββ BaseCIMigrationService.php
β βββ Analyzers/
β β βββ AbstractCIAnalyzerService.php # Base class for analyzers.
β β βββ CI2AnalyzerService.php
β β βββ CI3AnalyzerService.php
β β βββ CI4AnalyzerService.php
β βββ API/
β β βββ APICIProjectPreparationService.php
β β βββ APIMigrationService.php
β βββ CLI/
β β βββ CLIMigrationService.php
β βββ Converters/
β β βββ AbstractCIConverterService.php # Base class for converters.
β β βββ CI2ConverterService.php
β β βββ CI3ConverterService.php
β β βββ CI4ConverterService.php
β βββ Coordinators/
β β βββ AbstractCIMigrationCoordinatorService.php
β β βββ CI3MigrationCoordinatorService.php
β β βββ CIMigrationCoordinatorService.php # The main service that orchestrates the migration.
β βββ Parsers/
β β βββ AbstractParserVisitor.php
β β βββ GenericNodeVisitor.php
β β βββ NodeProcessors/ # Contains the logic for processing different types of PHP code.
β β βββ CIConfigNodeProcessorBase.php
β β βββ CIControllerNodeProcessorBase.php
β β βββ CIDatabaseNodeProcessorBase.php
β β βββ CIModelNodeProcessorBase.php
β β βββ CIRouteNodeProcessorBase.php
β β βββ CI2/
β β βββ CI3/
β β βββ CI4/
β βββ Utility/
β βββ PhpFileParser.php # A wrapper around nikic/php-parser.
βββ Support/
β βββ DatabaseConnectionConfig.php
β βββ DirectoryManager.php
βββ Traits/
βββ HasConsoleOutput.php
βββ HasDirectories.php
βββ HasStatusBar.php
The migration process is broken down into three main phases:
- Analysis: The
CIAnalyzerInterfaceimplementations scan the CodeIgniter project to identify its structure, version, and components (controllers, models, routes, etc.). - Conversion: The
CIConverterInterfaceimplementations take the information from the analysis phase and convert the CodeIgniter components to their Laravel equivalents. This is where the bulk of the work happens. - Coordination: The
CIMigrationCoordinatorInterfaceimplementations orchestrate the entire process, from creating the new Laravel project to running the analysis and conversion steps.
The conversion process itself is further broken down by using the nikic/php-parser library to parse the PHP code and then using a series of NodeProcessorInterface implementations to process the different types of nodes in the AST. This allows for a very granular and extensible approach to the conversion.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Write your code. Be sure to follow the existing code style and conventions.
- Write tests for your code. This is important!
- Submit a pull request.