https://github.com/s-damian/damian-php
PHP 8.4 Framework - Damian PHP - Skeleton
https://github.com/s-damian/damian-php
framework framework-php open-source open-source-framework open-source-project php php8 php84
Last synced: 3 months ago
JSON representation
PHP 8.4 Framework - Damian PHP - Skeleton
- Host: GitHub
- URL: https://github.com/s-damian/damian-php
- Owner: s-damian
- License: mit
- Created: 2022-08-12T07:32:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-23T12:50:00.000Z (8 months ago)
- Last Synced: 2025-03-23T22:25:14.528Z (4 months ago)
- Topics: framework, framework-php, open-source, open-source-framework, open-source-project, php, php8, php84
- Language: PHP
- Homepage:
- Size: 116 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Damian PHP Framework - Skeleton
> A powerful PHP Framework in **PHP 8.4** - Beautiful code & Elegant syntax
> SGBDR: Compatible with **MySQL** / **MariaDB** / **PostgreSQL**
This **Open Source Framework** is developed by [Stephen Damian](https://github.com/s-damian)
Here you have the source codes of the `skeleton`.
### Kernel source code
The `kernel` source codes for this Framework are in this package:
[Damian PHP Framework - Kernel - [damian-php-fw]](https://github.com/s-damian/damian-php-fw)
## Getting Started
### Requirements
* PHP `8.2` || `8.3` || `8.4`
### Create a new project
* You can create a new project via the `composer create-project` command:
```
composer create-project s-damian/damian-php example-app-name
```### Configuration
* Create your `.env` file:
```
cd /your-path/example-app-name
``````
cp .env.example .env
```* You have to configure the `.env` file.
### Configuration - HTTP Server
* You have to configure your web server (Linux / Nginx or Apache / MySQL or PostgreSQL / PHP).
You have an example Nginx Vhost configuration in `docs/nginx/vhost-example.conf` file.
### After configuring your HTTP server (Nginx), you can run these demo URLs
* http://www.your-domain.com
* http://www.your-domain.com/contact
* http://www.your-domain.com/blog
* http://www.your-domain.com/blog/slug-1
* http://www.your-domain.com/callable-example
* http://www.your-domain.com/sitemap## Documentation
* The documentation for this Framework is in `docs/DamianPhp` folder.
## Syntax examples
### Routing
An example of a route listing:
```php
'Front\\', 'prefix' => 'website'], function () {
Router::post(
'/contact',
'Contact@sendMail',
['name' => 'contact_send-mail']
);
Router::group(['prefix' => '/blog'], function () {
Router::get(
'',
'Article@index',
['name' => 'article_index']
);
Router::get(
'/{slug}',
'Article@show',
['name' => 'article_show']
);
});
});
```Retrieve a URL with the name of a route:
```php
$article->slug]); ?>
```### ORM (compatible with MySQL / MariaDB and PostgreSQL)
#### Active Record Pattern
Example to insert an article (using the `setters` magic methods):
```php
setTitle('Article 1');
$article->setDescription('Description');
$article->setContent('Content');
$article->setSlug('slug-1');
$article->save();
```Example to update an article (using the `fill` magic method):
```php
findOrFail($id);
$article->fill(Request::getPost()->all());
$article->save();
```#### Fetch multiple rows
Example using the `when` magic method:
```php
select('title, description, content')
->where('slug', '!=', 'article-2')
->when((int) Input::get('status') === 1, function ($query) {
return $query->where('status', '=', 1);
})
->findAll();
```#### ORM with Pagination
To paginate an item listing:
```php
where('status', '=', 1)->paginate(20);$pagination = $article->getPagination();
foreach ($articles as $article) {
echo $article->title;
}echo $pagination->render();
echo $pagination->perPageForm();
```### Pagination
```php
paginate($countElements);$limit = $pagination->getLimit();
$offset = $pagination->getOffset();// Here your list of items with a loop.
echo $pagination->render();
echo $pagination->perPageForm();
```### Validation
Validation example (you can do method injection):
```php
rules([ // Add your rules in the array.
'title' => ['max' => 190, 'required' => true],
'description' => ['max' => 190, 'required' => true],
'content' => ['required' => true],
]);if ($validator->isValid()) {
// Success
} else {
// Error
$validator->getErrorsHtml();
}
}
```You can add custom validation rules. Example:
```php