PHPackages                             andrewthecoder/arcmvc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. andrewthecoder/arcmvc

ActiveLibrary[Framework](/categories/framework)

andrewthecoder/arcmvc
=====================

A lightweight, modern PHP MVC framework. Small core, batteries included, built for PHP 8.4+ with immutable-friendly HTTP primitives.

v0.9.1(1mo ago)11MITPHPPHP &gt;=8.4

Since Jun 1Pushed 1mo agoCompare

[ Source](https://github.com/andrewthecodertx/php-arcmvc)[ Packagist](https://packagist.org/packages/andrewthecoder/arcmvc)[ RSS](/packages/andrewthecoder-arcmvc/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (10)Versions (3)Used By (0)

Arc
===

[](#arc)

A lightweight, modern PHP MVC framework. Small core, batteries included, built for PHP 8.4+.

Principles
----------

[](#principles)

- No hidden magic. Request flow is traceable from `public/index.php` to response.
- Decoupled core: uses a dedicated DI container for service management.
- Secure defaults: CSRF protection, XSS escaping, SQL injection prevention, security headers.
- Fast startup, low memory by default.
- One canonical way to do common things.
- First-party modules for the common website stack, each optional and independently replaceable.

Requirements
------------

[](#requirements)

- PHP 8.4+
- PDO extension (for database features)
- Composer

Quick Start
-----------

[](#quick-start)

```
# Create a new project (installs dependencies automatically)
arc new my-project
cd my-project
arc serve
```

Or add Arc to an existing project:

```
composer require andrewthecoder/arcmvc
cp -r vendor/andrewthecoder/arcmvc/skeleton/* .
```

Visit

Environment Setup
-----------------

[](#environment-setup)

Copy `.env.example` to `.env` and adjust values:

```
cp .env.example .env
```

Arc includes a built-in `.env` loader. Load it early in your bootstrap:

```
use Arc\Config\EnvLoader;
EnvLoader::load(__DIR__ . '/../.env');
```

Environment variables are available via `$_ENV` and `getenv()`. Existing env vars are never overwritten.

Routing
-------

[](#routing)

Define routes in `routes/web.php`:

```
$router->get('/', [HomeController::class, 'index']);
$router->get('/users/{id}', [UserController::class, 'show']);
$router->post('/users', [UserController::class, 'store']);
$router->put('/users/{id}', [UserController::class, 'update']);
$router->delete('/users/{id}', [UserController::class, 'destroy']);
```

Route groups with prefix and middleware:

```
$router->group(['prefix' => 'admin', 'middleware' => [AuthMiddleware::class]], function ($router) {
    $router->get('/dashboard', [AdminController::class, 'index']);
});
```

Controllers
-----------

[](#controllers)

Controllers extend `Arc\Support\Controller` and receive the current request via `setRequest()`:

```
use Arc\Support\Controller;
use Arc\Http\Request;
use Arc\Http\Response;

class UserController extends Controller
{
    public function show(Request $request, string $id): Response
    {
        $user = User::find($id);
        return $this->view('users.show', ['user' => $user]);
    }

    public function store(Request $request): Response
    {
        return $this->redirect('/users');
    }

    protected function back(): Response // Safe redirect, rejects external URLs
    {
        return parent::back();
    }
}
```

Controllers are resolved through the DI container, enabling constructor injection.

Views and Templates
-------------------

[](#views-and-templates)

Views live in `resources/views/` and use `.phtml` files:

```
