PHP Classes

How to Use a PHP MVC Framework to Develope PHP Web Applications Using the Package Catalyst: Framework to develop MVC-based PHP applications

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-06-13 (Less than 1 hour ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
catalyst 1.0MIT/X Consortium ...7.1Libraries, Design Patterns, PHP 7
Description 

Authors

Walter Nuñez
Catalyst Community


Contributor

This package can framework to develop MVC-based PHP applications.

It provides several classes to implement different aspects of a PHP Web application.

Currently, it provides:

- Process argument parameters

- Access databases using PDO

- Process Web and API requests and generate responses

- Send email from templates

- Process requests routing to controllers

- Manage session variables

- Generate views from layouts

- Etc.

Picture of Francisco Núñez
  Performance   Level  
Innovation award
Innovation award
Nominee: 2x

 

Instructions

Please read this document to learn how to install and use this PHP MVC framework.

Example

<?php

declare(strict_types=1);

/**************************************************************************************
 *
 * Catalyst PHP Framework
 * PHP Version 8.3 (Required).
 *
 * @package Catalyst
 * @subpackage Public
 * @see https://github.com/arcanisgk/catalyst
 *
 * @author Walter Nuñez (arcanisgk/original founder) <[email protected]>
 * @copyright 2023 - 2025
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 *
 * @note This program is distributed in the hope that it will be useful
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @category Framework
 * @filesource
 *
 * @link https://catalyst.dock Local development URL
 *
 */

use Catalyst\Framework\Core\Argument\Argument;
use
Catalyst\Kernel;

require_once
realpath(implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', '..', 'vendor', 'autoload.php']));

// Bootstrap the application
$app = new Kernel();

try {
   
$app->bootstrap();

   
// Parse command line arguments
   
$args = new Argument();

   
// Register commands
    // Format: command:action => [handler class, method]
   
$commands = [];

   
// Get the command from arguments
   
$command = $args->getCommand();

    if (empty(
$command)) {
       
// List available commands if none specified
       
echo "Available commands:\n";
        foreach (
array_keys($commands) as $cmd) {
            echo
" $cmd\n";
        }
        echo
"\nUse 'php cli.php command --help' for more information on a command.\n";
        exit(
0);
    }

   
// Execute the command if registered
   
if (isset($commands[$command])) {
        [
$handlerClass, $method] = $commands[$command];
       
$handler = new $handlerClass();
       
$handler->$method($args);
    } else {
        echo
"Unknown command: $command\n";
        echo
"Use 'php cli.php' to see available commands.\n";
        exit(
1);
    }

} catch (
Exception $e) {
    echo
'Error: ' . $e->getMessage() . NL;
    exit(
1);
}


Details

Catalyst PHP Framework

Catalyst is a modern PHP framework designed with flexibility, performance, and developer experience in mind. It combines established architectural patterns with pragmatic solutions to create a robust foundation for PHP applications.

Overview

Catalyst is a PHP framework developed by Walter Nuñez (arcanisgk) that combines the best aspects of various architectural patterns to create a flexible yet powerful development environment. The framework requires PHP 8.3 and is distributed under the MIT License.

Philosophy

Catalyst is built on several key principles:

  1. Practical Flexibility - Use the right pattern for the right job, rather than forcing a single approach
  2. Separation of Concerns - Clear boundaries between components with single responsibilities
  3. Developer-First Experience - Intuitive APIs and comprehensive error handling
  4. Framework/Application Separation - Clear distinction between framework internals and application code

Architecture

Dual-Space Design

Catalyst uses a dual-space architecture that explicitly separates framework code from application code:

  • Framework Space (`app/Assets/Framework/`) - Contains core framework components, not intended for direct modification
  • Application Space (`app/Repository/`) - Dedicated development area for application-specific code

This separation allows for framework updates without disrupting application code, while still providing all the extension points needed for customization.

Mixed-Pattern Implementation

Unlike frameworks that rigidly adhere to a single pattern, Catalyst strategically employs multiple architectural patterns where they make the most sense:

  • MVC Pattern - For structured request handling and response generation
  • Repository Pattern - For data access abstraction
  • Entity Pattern - For domain object encapsulation
  • Service Pattern - For reusable business logic
  • Singleton Pattern - For services that genuinely need global state

This mixed approach allows developers to use familiar patterns while avoiding their limitations.

Internationalization

Catalyst provides built-in support for multi-language applications:

  • JSON-based translation files organized by language and feature
  • Simple translation helpers (`t()` and `__()`)
  • Language switching capabilities

Error Management

The framework includes a comprehensive error management system:

  • Detailed error reporting in development environments
  • Production-safe error handling
  • Customizable error logging and display

Key Components

Core Framework

  • Routing System - Flexible URL-to-controller mapping with middleware support
  • View Engine - Template rendering with layouts and partials
  • Response Handling - Type-specific responses (HTML, JSON, redirects)
  • Middleware Stack - Modular request processing pipeline

Utility Layer

  • Logging - Type-categorized logging with formatting support
  • Debugging - Development tools for inspection and troubleshooting
  • File Operations - Simplified file system interactions
  • CLI Support - Command-line interface with dedicated entry point

Getting Started

Requirements

  • PHP 8.3 or higher
  • Composer
  • Web server with URL rewriting capability (Apache, Nginx)

Installation

composer create-project arcanisgk/catalyst my-project
cd my-project

Basic Usage

  1. Define routes in `bootstrap/routes/web.php`
  2. Create controllers in `app/Repository/Controllers`
  3. Add views in `app/Repository/Views`
  4. Run your application through a web server pointing to the `public` directory

Development Roadmap

  • Enhanced database abstraction layer
  • Advanced middleware capabilities
  • Expanded CLI tools
  • Extended documentation and tutorials

License

Catalyst is open-sourced software licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For documentation and more information, visit catalyst.lh-2.net.


  Files folder image Files (176)  
File Role Description
Files folder imageapp (1 file, 1 directory)
Files folder imagebootstrap (6 directories)
Files folder imagecache (1 file, 1 directory)
Files folder imagelogs (1 directory)
Files folder imagepublic (6 files, 1 directory)
Files folder imagetest (1 file)
Accessible without login Plain text file .env Data Auxiliary data
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file .env.production Data Auxiliary data
Accessible without login Plain text file ARCHITECTURE.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file directory.txt Doc. Documentation
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file tree.txt Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0