PHPackages                             pillardash/lay - 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. pillardash/lay

ActiveLibrary[Framework](/categories/framework)

pillardash/lay
==============

A lite PHP builder meta-framework to get your projects up and running quickly

v0.1.5(3mo ago)05MITJavaScriptPHP &gt;8.1

Since Aug 15Pushed 3mo agoCompare

[ Source](https://github.com/pillardash/lay)[ Packagist](https://packagist.org/packages/pillardash/lay)[ RSS](/packages/pillardash-lay/feed)WikiDiscussions stable Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (8)Used By (0)

[![Lay Framework](https://raw.githubusercontent.com/pillardash/lay-core/refs/heads/stable/src/static/img/logo.png)](https://raw.githubusercontent.com/pillardash/lay-core/refs/heads/stable/src/static/img/logo.png)
====================================================================================================================================================================================================================

[](#)

**Lay** - A Lite PHP Meta-Framework for Rapid Development

[![PHP Version](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Framework Version](https://camo.githubusercontent.com/ba5e54082d7b47b300cca8e7c2df52e3410ac73253ce907ed7cabe196e7588cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f56657273696f6e2d302e782d6f72616e67652e737667)](https://github.com/pillardash/lay)

Lay is a modern, lightweight PHP meta-framework designed to get your projects up and running quickly. Built with developer experience in mind, it provides a clean architecture with powerful features while maintaining simplicity.

✨ Key Features
--------------

[](#-key-features)

- **🚀 Rapid Development** - Get started in minutes with sensible defaults
- **🏗️ Domain-Driven Architecture** - Organize your application by domains/modules
- **🔌 Built-in API Support** - RESTful APIs with automatic routing and rate limiting
- **📱 Modern Frontend Integration** - Built-in JavaScript utilities and asset management
- **🗄️ Database Agnostic** - Support for MySQL, PostgreSQL, and SQLite
- **🔒 Security First** - CORS, CSRF protection, and secure session management
- **⚡ Performance Optimized** - Asset compression, caching, and production optimizations
- **🎨 Flexible View System** - Clean templating with PHP or integrate your favorite frontend

🚀 Quick Start
-------------

[](#-quick-start)

### Installation

[](#installation)

Create a new Lay project using Composer:

```
composer create-project pillardash/lay my-awesome-project
cd my-awesome-project
```

### Environment Setup

[](#environment-setup)

1. Copy the environment file and configure your settings:

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

2. Edit `.env` to match your environment:

```
# Set your environment
APP_ENV=DEVELOPMENT

# Database configuration (optional)
DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_USERNAME=root
DB_PASSWORD=your_password
DB_NAME=your_database
```

### Start Development Server

[](#start-development-server)

```
# Using PHP built-in server
php -S localhost:8000

# Or using your preferred local server (Apache, Nginx, etc.)
```

Visit `http://localhost:8000` and you'll see your Lay application running! 🎉

📁 Project Structure
-------------------

[](#-project-structure)

```
my-project/
├── bricks/                 # Business logic layer
│   └── Business/
│       ├── Api/            # API hooks and logic
│       ├── Controller/     # Application controllers
│       ├── Model/          # Data models
│       ├── Request/        # Request validation classes
│       └── Resource/       # API resource transformers
├── utils/                  # Utility classes and helpers
├── web/                    # Web layer
│   ├── domains/           # Domain-specific code
│   │   ├── Api/           # API domain
│   │   │   ├── Plaster.php    # API configuration and hooks
│   │   │   └── index.php      # API entry point
│   │   └── Default/       # Default web domain (template for all regular domains)
│   │       ├── Plaster.php    # Domain routes and page configuration
│   │       ├── foundation.php # Domain-specific setup
│   │       ├── layout/        # HTML layout components
│   │       │   ├── head.inc   #  section (meta, CSS, etc.)
│   │       │   ├── body.inc   # Main body wrapper
│   │       │   └── script.inc # JavaScript includes
│   │       ├── plaster/       # View templates
│   │       │   ├── homepage.view   # Homepage template
│   │       │   └── another.view    # Example page template
│   │       └── public/        # Domain-specific public assets
│   │           ├── index.php      # Domain entry point
│   │           ├── favicon.ico    # Domain favicon
│   │           └── static/        # Static assets (CSS, JS, images)
│   │               └── dev/       # Development assets
│   │                   ├── css/   # Stylesheets
│   │                   ├── js/    # JavaScript files
│   │                   ├── images/ # Images
│   │                   └── ui/    # UI components
│   └── shared/            # Shared assets and resources
├── foundation.php         # Application bootstrap
├── index.php             # Application entry point
└── bob.config.json       # Build and deployment configuration

```

🏗️ Core Concepts
----------------

[](#️-core-concepts)

### Domains

[](#domains)

Lay organizes applications into **domains** - self-contained modules that handle specific parts of your application:

```
Domain::new()->create(
    id: "api-endpoint",
    builder: \Web\Api\Plaster::class,
    pattern: "api",
    type: DomainType::SPECIAL,
);

Domain::new()->create(
    id: "default",
    builder: \Web\Default\Plaster::class,
    pattern: "*",
    type: DomainType::REGULAR,
);
```

### Domain Structure

[](#domain-structure)

Each regular domain follows a standard structure (using `Default` as an example):

```
web/domains/Default/
├── Plaster.php           # Main domain controller - defines routes and pages
├── foundation.php        # Domain-specific configuration and setup
├── layout/              # HTML layout components
│   ├── head.inc         #  section - meta tags, CSS includes
│   ├── body.inc         # Main body wrapper and footer
│   └── script.inc       # JavaScript includes and initialization
├── plaster/             # View templates (your actual page content)
│   ├── homepage.view    # Homepage template
│   └── another.view     # Additional page templates
└── public/              # Domain-specific public assets
    ├── index.php        # Domain entry point for direct access
    ├── favicon.ico      # Domain-specific favicon
    └── static/          # Static assets organized by environment
        └── dev/         # Development assets
            ├── css/     # Domain stylesheets
            ├── js/      # Domain JavaScript
            ├── images/  # Domain images
            └── ui/      # UI components and assets

```

**Key Files Explained:**

- **`Plaster.php`** - Your domain's main controller where you define routes and configure pages
- **`layout/*.inc`** - Reusable HTML components that wrap your content
- **`plaster/*.view`** - Your actual page templates with content
- **`public/static/`** - All your CSS, JavaScript, images, and other assets

### Controllers

[](#controllers)

Controllers handle your application logic using traits for common functionality:

```
class NewsletterSubController
{
    use IsSingleton, ControllerHelper;

    public function add(): array
    {
        $request = new SubNewsletterRequest();

        if ($request->error)
            return self::res_warning($request->error);

        // Your logic here...
        return self::res_success("Success message");
    }
}
```

### Models

[](#models)

Models extend `BaseModelHelper` for database operations:

```
class NewsletterSub extends BaseModelHelper
{
    public static string $table = "newsletter_subs";

    protected function cast_schema(): void
    {
        $this->cast("options", "array");
    }
}
```

🔌 Building APIs
---------------

[](#-building-apis)

### API Hooks

[](#api-hooks)

Define your API endpoints using the hook system:

```
class Hook extends ApiHooks
{
    protected function hooks(): void
    {
        $this
            ->post("subscribe-newsletter")->bind(fn() => NewsletterSubController::new()->add())
            ->get("list-subscribers/{page}")->bind(fn($page) => NewsletterSubController::new()->list((int) $page));
    }
}
```

### Request Validation

[](#request-validation)

Create request classes for automatic validation:

```
class SubNewsletterRequest extends RequestHelper
{
    protected function rules(): void
    {
        $this->vcm(['field' => 'name', 'required' => false ]);
        $this->vcm(['field' => 'email', 'is_email' => true ]);
    }
}
```

🎨 Frontend Development
----------------------

[](#-frontend-development)

Lay includes a minimal but powerful JavaScript library for frontend interactions:

```
// Built-in DOM utilities
$id('my-element').innerHTML = 'Hello World';
$sel('.my-class').$class('add', 'active');

// AJAX made simple
$ajax($lay.src.api + 'subscribe-newsletter', {
    method: 'POST',
    data: { email: 'user@example.com' },
}).then(response => {
    console.log('Success!', response);
    osNote("Success", "success")
});
```

🗄️ Database Integration
-----------------------

[](#️-database-integration)

Lay can startup without connecting to the database by default, but if you want that, you can use the `->connect_db()` method in your `foundation.php`:

```
Startup::new()
    ->name($site_name, "$site_name | Slogan Goes Here")
    ->connect_db()
    ->set_globals([
        "desc" => "Your project description"
    ]);
```

🚀 Deployment
------------

[](#-deployment)

Lay includes production optimizations:

- **Asset Compression** - Automatic JS/CSS minification
- **HTML Compression** - Reduced payload sizes
- **Caching** - Domain and asset caching
- **Security Headers** - Production-ready security configuration

Configure in your `.env`:

```
APP_ENV=PRODUCTION
COMPRESS_HTML=true
COMPRESS_ASSETS=true
CACHE_DOMAINS=true
```

📚 Learning Resources
--------------------

[](#-learning-resources)

- **Official Documentation**:  *(Coming Soon)*
- **Example Applications**: Check the `web/domains/Default` folder for examples
- **Community**: Join our discussions and get help from the community

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.

📄 License
---------

[](#-license)

Lay is open-source software licensed under the [MIT License](LICENSE).

---

**Ready to build something amazing?** 🚀

```
composer create-project pillardash/lay my-next-project
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance78

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~39 days

Total

6

Last Release

117d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a68dd45016c0b4c8eb12919f751f4791e50c3651c31f3d7790a952306cfa7d1?d=identicon)[leonardosahon](/maintainers/leonardosahon)

---

Top Contributors

[![leonardosahon](https://avatars.githubusercontent.com/u/54501513?v=4)](https://github.com/leonardosahon "leonardosahon (110 commits)")

---

Tags

fast php frameworkmetaframeworklaylite php frameworkbricklayerphp bricklayer

### Embed Badge

![Health badge](/badges/pillardash-lay/health.svg)

```
[![Health](https://phpackages.com/badges/pillardash-lay/health.svg)](https://phpackages.com/packages/pillardash-lay)
```

###  Alternatives

[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)[nette/bootstrap

🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.

68535.8M592](/packages/nette-bootstrap)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
