PHPackages                             caiquebispo/laraslim - 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. caiquebispo/laraslim

ActiveProject[Framework](/categories/framework)

caiquebispo/laraslim
====================

A lightweight PHP microframework combining Slim and Laravel features for fast and structured API development.

1.3.2(1y ago)83MITPHPPHP ^8.4

Since Apr 15Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/caiquebispo/LaraSlim)[ Packagist](https://packagist.org/packages/caiquebispo/laraslim)[ RSS](/packages/caiquebispo-laraslim/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (13)Versions (7)Used By (0)

 [![LaraSlim Logo](https://camo.githubusercontent.com/ec1a32c405dbd2a6f664851a35a27385d7a8323183d36e2114c16c4b08f1f416/68747470733a2f2f692e706f7374696d672e63632f717132336d7057352f436861742d4750542d496d6167652d31342d64652d6162722d64652d323032352d30382d30392d35332e706e67)](https://camo.githubusercontent.com/ec1a32c405dbd2a6f664851a35a27385d7a8323183d36e2114c16c4b08f1f416/68747470733a2f2f692e706f7374696d672e63632f717132336d7057352f436861742d4750542d496d6167652d31342d64652d6162722d64652d323032352d30382d30392d35332e706e67)

 [![Latest Stable Version](https://camo.githubusercontent.com/0b44f21180570a0f624ddda31d95834a1bdabb06c35568f7c1c4067e261cc952/687474703a2f2f706f7365722e707567782e6f72672f636169717565626973706f2f6c617261736c696d2f76)](https://packagist.org/packages/caiquebispo/laraslim) [![Total Downloads](https://camo.githubusercontent.com/a55ce2cd758f9fdf4bf896f241c3bb8f92b0d7b6f3a2fa25382a12812dfdfb49/687474703a2f2f706f7365722e707567782e6f72672f636169717565626973706f2f6c617261736c696d2f646f776e6c6f616473)](https://packagist.org/packages/caiquebispo/laraslim) [![Latest Unstable Version](https://camo.githubusercontent.com/5ea32d67f807a4a7c2e91afdbfda99b68ca361ef28407ba275026566957d93fd/687474703a2f2f706f7365722e707567782e6f72672f636169717565626973706f2f6c617261736c696d2f762f756e737461626c65)](https://packagist.org/packages/caiquebispo/laraslim) [![License](https://camo.githubusercontent.com/cf3114a9cbff4a984a70f26e67f5e7892a54448b8b5af1b0158975e1dd186028/687474703a2f2f706f7365722e707567782e6f72672f636169717565626973706f2f6c617261736c696d2f6c6963656e7365)](https://packagist.org/packages/caiquebispo/laraslim) [![PHP Version Require](https://camo.githubusercontent.com/7fdac97bad1bb40a2f3d2cf19f32f270fd8496f622f50aafc4b844e4ce40d650/687474703a2f2f706f7365722e707567782e6f72672f636169717565626973706f2f6c617261736c696d2f726571756972652f706870)](https://packagist.org/packages/caiquebispo/laraslim)

Description
-----------

[](#description)

**LaraSlim** is a microframework for PHP that combines the lightness of the [Slim Framework](https://www.slimframework.com/) with a structure inspired by [Laravel](https://laravel.com/). It's ideal for creating clean, modular APIs with a lightweight and fast setup.

> **Note:** This project **does not include an authentication engine** by default. You can integrate your own or use third-party libraries.

It also doesn't include a template engine, but you can integrate it with Blade (Laravel) or any other engine of your choice.

> ⚠️ This is a **beta** project: some features may be under development and bugs may occur.

---

Features
--------

[](#features)

- 🚀 **Lightweight &amp; Fast** - Built on Slim Framework 4
- 🔒 **Security First** - CORS and Security Headers middlewares included
- 📝 **Centralized Error Handling** - PSR-3 logging, JSON error responses
- 🐳 **Docker Ready** - Multi-stage builds for dev and production
- ✅ **Testing Infrastructure** - Pest PHP with HTTP testing helpers
- 🔧 **Environment Validation** - Automatic validation of required variables

---

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

[](#requirements)

- PHP ^8.4
- Docker (optional)
- Composer

---

Installation via Composer
-------------------------

[](#installation-via-composer)

```
composer create-project caiquebispo/laraslim example_app
```

---

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

[](#quick-start)

### Using PHP Built-in Server

[](#using-php-built-in-server)

```
cd example_app
cp .env.example .env
composer install
php -S localhost:8008 -t public
```

### Using Docker

[](#using-docker)

```
# Development
docker compose up

# Production
docker compose --profile production up
```

---

Docker Commands
---------------

[](#docker-commands)

CommandDescription`./bin/build`Build Docker containers`./bin/up`Start Docker containers`./bin/attach`Attach to container`./bin/down`Stop Docker containers---

Application Access
------------------

[](#application-access)

- **API**: `http://localhost:8003` (Docker) or `http://localhost:8008` (PHP server)
- **PHPMyAdmin**: `http://localhost:8080` (User: `root`, Password: `root`)

---

Project Structure
-----------------

[](#project-structure)

```
app/
├── Contracts/          # Interfaces and contracts
├── Http/
│   ├── Controllers/    # Application controllers
│   ├── Middleware/     # CORS, Security Headers
│   └── Request/        # Form validation
├── Kernel/
│   ├── Exceptions/     # HttpException, ValidationException, Handler
│   └── Providers/      # Service providers (Logging, Database, etc.)
├── Models/             # Eloquent models
├── DTOs/               # Data Transfer Objects
└── Services/           # Business logic
config/
├── app.php             # Application config
├── cors.php            # CORS configuration
└── environments.php    # Environment validation
tests/
├── Feature/            # Feature tests
├── Unit/               # Unit tests
└── Traits/             # Test helpers (DatabaseMigrations, WithFaker)

```

---

Environment Configuration
-------------------------

[](#environment-configuration)

Copy `.env.example` to `.env` and configure:

```
# Application
APP_ENV=local
APP_DEBUG=true

# Database (MySQL)
DB_CONNECTION=mysql
DB_HOST=mysql
DB_DATABASE=LaraSlim_db
DB_USERNAME=root
DB_PASSWORD=root

# Or SQLite
DB_CONNECTION=sqlite
DB_DATABASE=../storage/database.sqlite
```

---

Artisan Commands
----------------

[](#artisan-commands)

```
php artisan-slim make:migration users
php artisan-slim make:model User
php artisan-slim make:controller UserController
php artisan-slim make:request UserRequest
php artisan-slim          # List all commands
```

---

Response Helpers
----------------

[](#response-helpers)

```
use LaraSlim\Kernel\Providers\Response;

// Success response
return response()->success($data, 'Created', 201);

// Error response
return response()->error('Not found', 404);

// Validation error
return response()->validationError($errors);

// Paginated response
return response()->paginate($items, $total, $page, $perPage);
```

---

Exception Handling
------------------

[](#exception-handling)

```
use LaraSlim\Kernel\Exceptions\HttpException;

// Throw HTTP exception
throw HttpException::notFound('User not found');
throw HttpException::unauthorized();

// Or use helpers
abort(404, 'Resource not found');
abort_if($condition, 403, 'Forbidden');
```

---

Helper Functions
----------------

[](#helper-functions)

FunctionDescription`env($key, $default)`Get environment variable`config($key, $default)`Get config value (dot notation)`response()`Get Response helper instance`abort($code, $message)`Throw HTTP exception`logger()`Get PSR-3 logger`info($message)`Log info message`base_path($path)`Get base path`storage_path($path)`Get storage path---

Security
--------

[](#security)

LaraSlim includes built-in security middlewares:

- **CORS** - Configurable via `config/cors.php` or environment variables
- **Security Headers** - X-Frame-Options, X-Content-Type-Options, HSTS (production)

---

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Or just Pest
vendor/bin/pest

# With coverage
vendor/bin/pest --coverage
```

---

Examples
--------

[](#examples)

### Route Group

[](#route-group)

```
use Slim\Routing\RouteCollectorProxy;

$app->group('/api', function (RouteCollectorProxy $group) {
    $group->get('/users', 'UserController:index');
    $group->post('/users', 'UserController:store');
});
```

### Controller with Response Helper

[](#controller-with-response-helper)

```
