Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
# MaplePHP CLI App
# MaplePHP Framework - Made for developers who still enjoy programming

A lightweight CLI application skeleton built on the MaplePHP ecosystem. It provides a modern command-line framework with routing, controllers, dependency injection, services, and PSR-compatible components so you can build any CLI application or automation tool.
MaplePHP is a high performance PHP framework built on PSR standards and modern best practices. It includes the core components needed for real applications such as MVC, dependency injection, routing, caching, logging, error handling, HTTP clients, and support for both web and CLI environments.

This project is intended to be installed using Composer’s `create-project` and serves as the starting point for CLI applications.
The goal is not to lock developers into a fixed ecosystem. MaplePHP gives you a robust core while letting you use the libraries and tools you prefer. You can shape the framework around your own stack and workflow, while still benefiting from updates and improvements to the core. This keeps your project flexible, maintainable, and truly yours.

Your code. Your libraries. Your framework.

## Installation

Create a new project:

```bash
composer create-project maplephp/cli-app my-app
composer create-project maplephp/maplephp my-app
cd my-app
````

Run the CLI:
Run the MaplePHP development server:

```bash
./cli
./maple serve
```

## Usage

Typical commands:

```bash
./cli list
./cli run --arg=1
./cli help
```


## Project Structure

Example structure:
Expand All @@ -39,7 +30,10 @@ my-app/
├── app/
│ ├── Controllers/
│ └── Services/
├── configs/
├── public/
├── routers/
├── storage/
├── vendor/
```

Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "vendor/bin/unitary",
"serve": [
"Composer\\Config::disableProcessTimeout",
"@php -S localhost:8000 -t public"
"./maple serve"
]
},
"require": {
Expand All @@ -37,6 +37,12 @@
"Configs\\": "configs/"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.x-dev",
"dev-develop": "1.x-dev"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 1 addition & 1 deletion configs/ConfigProps.php → configs/CliOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* - Null values allow the system to distinguish between "not provided" and "intentionally set".
* - Do not use array values or multiple data types
*/
class ConfigProps extends AbstractConfigProps
class CliOptions extends AbstractConfigProps
{
public ?string $timezone = null;
public ?string $locale = null;
Expand Down
14 changes: 13 additions & 1 deletion routers/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
* Web router
*
* @var RouterDispatcher $router
*
* FastRoute parameter patterns:
*
* {name} Matches any segment except "/". (Example: /user/{name})
*
* {id:\d+} Matches numeric values only. (Example: /post/{id})
*
* {name:[^/]+} Explicit single path segment. (Example: /profile/{name:[^/]+})
*
* {slug:.+} Matches everything including slashes. (Example: /cat/{slug:.+})
*
* {lang:(en|sv|de)} Restricts parameter to specific values. (Example: /{lang}/docs)
*/

use App\Controllers\StartController;
use MaplePHP\Core\Router\RouterDispatcher;

$router->get("/", [StartController::class, "index"]);
$router->get("/{page:.+}", [StartController::class, "show"]);
$router->get("/{page}", [StartController::class, "show"]);
24 changes: 24 additions & 0 deletions tests/unitary-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* This is just a test example using MaplePHP Unitary testing framework
* Read more: https://maplephp.github.io/Unitary/
*/

use MaplePHP\Unitary\{Expect, TestCase};

group("Your test subject", function (TestCase $case) {

// Test example 1 - simple
$case->expect("YourValue")->isEqualTo("YourValue");

// Test example 2 - Encapsulate
$case->describe("Validate a string value")
->expect(function (Expect $expect) {

$expect->expect("YourValue")
->isLength(9)
->isString()
->assert("Value is not valid");
});

});