PHPackages                             fragment/elemental - 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. fragment/elemental

ActiveProject[Framework](/categories/framework)

fragment/elemental
==================

A PHP framework without any strings attached, but with all the magical features.

v1.0.0(2y ago)16MITPHPPHP &gt;=8.0.0

Since Jan 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AneesMuzzafer/elemental-composer)[ Packagist](https://packagist.org/packages/fragment/elemental)[ Docs](https://github.com/AneesMuzzafer/elemental)[ RSS](/packages/fragment-elemental/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Elemental
=========

[](#elemental)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

> **Please Note:** This repository contains the code of the Elemental framework suited for installation via Composer. If you prefer to clone the application and run it without dependencies like Composer, please visit the main [Elemental repository](https://github.com/AneesMuzzafer/elemental).

Elemental is a PHP framework developed from scratch for dynamic, user-friendly coding experiences. It incorporates features such as Dependency Injection and follows the MVC architecture to streamline web development and improve code organization. Engineered with a passion for simplicity and flexibility, it invites developers into a realm where they can wield unparalleled control and gain a profound understanding of the tools at their disposal.

Features:
---------

[](#features)

- [Powerful Dependency Injection Container ](#dependency-injection-container)
- [Fast Routing Engine](#routing)
- [Route Model Binding](#route-model-binding)
- [Inbuilt Object Relational Mapper (ORM)](#object-relational-mapper-model)
- [Command Line Engine - Candle](#candle-command-line-engine)
- [View Composition with Components and Layouts](#views)
- [Middlewares](#middleware)
- [Custom Exception Handling](#exception-handler)
- [MVC Architecture](#controllers)
- [Facades](#facades)
- [No External Dependency](#why-choose-elemental)

Demo - Inkwell
--------------

[](#demo---inkwell)

To showcase the capabilities of Elemental, a fully working platform called **[Inkwell](https://inkwell.anees.dev)** has been developed using Elemental. Inkwell is a unique space dedicated to the pure essence of storytelling. In line with Elemental's goal of having no external dependencies, Inkwell has been crafted using plain HTML, CSS, JS, and PHP only.

- **Explore the demo: [Inkwell](https://inkwell.anees.dev)**
- **GitHub Repository: [Inkwell GitHub](https://github.com/AneesMuzzafer/Inkwell)**

Feel free to delve into both the live platform and the corresponding codebase. Explore Inkwell's features to understand how Elemental can be harnessed for your own projects.

See the [inspiration](#inspiration) behind the creation of **Elemental**.

Why Choose Elemental?
---------------------

[](#why-choose-elemental)

Elemental has been designed with the aim of having no strings attached. There are no dependencies on external libraries or frameworks. The aim is to give the developers a genuine sense of control—an open door to independently explore and understand the magical stuff that powers the framework.

The overarching goal? Let developers fully embrace and leverage the elegance of powerful abstractions like DI containers, ORMs, Middlewares, and more. But here's the kicker—Elemental is not just pointing the way. It is handing you the keys to unravel the mysteries, empowering you to explore how these abstractions are laid out in the code.

In fact, you are encouraged not just to follow the path but to venture off the beaten track. Dive into the codebase, dissect the abstractions, and understand their inner workings. Feel free to tweak and experiment, for Elemental is not just a framework—it's an open invitation to shape and mold the tools at your disposal. Because coding shouldn't be a maze; it should be a journey. Let's make that journey together. 🚀

Documentation
-------------

[](#documentation)

1. [Getting Started](#getting-started)
2. [Dependency Injection Container](#dependency-injection-container)
3. [Routing](#routing)
4. [Controllers](#controllers)
5. [Request](#request)
6. [Responses](#responses)
7. [Middleware](#middleware)
8. [Views, Layouts and Components](#views)
9. [Database](#database)
10. [Models (ORM)](#object-relational-mapper-model)
11. [Candle](#candle-command-line-engine)
12. [Helpers](#helpers)
13. [Exception Handler](#exception-handler)
14. [Configuration](#configuration)
15. [Facades](#facades)

Getting Started
---------------

[](#getting-started)

### Creating Your First Elemental App

[](#creating-your-first-elemental-app)

Unlike other frameworks, Elemental doesn't rely on Composer or external libraries. It's as simple as cloning the repository and getting started with good ol' PHP installed on your system.

#### Cloning the Repository

[](#cloning-the-repository)

Open your terminal and execute the following command:

```
git clone https://github.com/aneesmuzzafer/elemental.git
```

No worries about package managers or dependencies – Elemental is built from scratch to free you from such concerns.

#### Alternatively, via Composer

[](#alternatively-via-composer)

For those who prefer the Composer route, creating a new Elemental app is just a command away:

```
composer create-project fragment/elemental sample-app
```

This will generate a project with a `composer.json` file.

Once your project is ready, kickstart the Elemental local development server with the `ignite` command using our command line engine, *Candle*:

```
cd sample-app

php candle ignite
```

Voila! Your application is now accessible at [http://127.0.0.1:8000](http://127.0.0.1:8000/).

We've taken care of the basic setup so you can focus on the magic.

> **Let the enchantment begin!**

Dependency Injection Container
------------------------------

[](#dependency-injection-container)

The most important feature of the Elemental is it's Dependency Injection Container which it uses for managing class dependencies and performing dependency injection.

Dependency Injection is a design pattern in software development that deals with how components get hold of their dependencies. In a traditional system, a class is responsible for creating its own dependencies. With DI, the responsibility of creating and providing dependencies is moved outside the class. Instead of a class creating its dependencies, they are "injected" into the class from an external source.

DI helps in achieving loosely coupled and more maintainable code. It promotes the separation of concerns by allowing each class to focus on its specific functionality without worrying about how to create or obtain its dependencies.

Dependency Injection is a specific implementation of the broader concept known as Inversion of Control (IoC). IoC represents a design paradigm where the control flow of a program is inverted or handed over to an external entity, container or framework.

### Automatic Dependency Resolution

[](#automatic-dependency-resolution)

In Elemental, when you're using dependency injection (DI), if a class doesn't rely on any other classes or only relies on concrete classes (not abstract interfaces), you don't need to explicitly tell the DI container how to create an instance of that class. The DI container will automatically figure it out.

The container will attempt to create an instance of the class, and if that class has dependencies on other classes, the container will recursively try to resolve those dependencies as well. This process continues until all the necessary classes are successfully resolved. So, you don't have to manually specify how to create each class – the DI container takes care of it for you.

```
