PHP Framework - Damian PHP - Skeleton

Overview

Tests Static analysis Latest Stable Version License

Damian PHP Framework - Skeleton

A powerful PHP Framework in PHP 8.1 - Beautiful code & Elegant syntax

This Open Source Framework is developed by Stephen 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]

Getting Started

Requirements

  • PHP >= 8.1

Ccreate 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

Documentation

  • The documentation for this Framework is in docs/DamianPhp folder.

Syntax examples

Routing

An example of a route listing:

<?php

Router::group(['namespace' => 'Front\\', 'prefix' => 'website'], function () {
    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 echo route('article_show', ['slug' => $article->slug]); ?>

ORM (compatible with MySQL and PostgreSQL)

Active Record Pattern

Example to insert an article (using the setters magic methods):

<?php

$article = new Article();
$article->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

$article = Article::load()->findOrFail($id);
$article->fill(Request::getPost()->all());
$article->save();

Fetch multiple rows

Example using the when magic method:

<?php

$articles = Article::load()
    ->select('title, description, content')
    ->where('id', '!=', 1)
    ->when((int) Input::get('status') === 1, function ($query) {
        return $query->where('status', '=', 1);
    })
    ->findAll();

ORM with Pagination

To paginate an item listing:

<?php

$article = new Article();

$articles = $article->where('status', '=', 1)->paginate(20);

$pagination = $article->getPagination();

foreach ($articles as $article) {
    echo $article->title;
}

echo $pagination->render();
echo $pagination->perPageForm();

Pagination

<?php

$pagination = new Pagination();

$pagination->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

public function update(Validator $validator, int $id)
{
    $validator->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

Validator::extend('strictly_equal', function ($input_name, $input_value, $parameters) {
    return (string) $input_value === (string) $parameters;
});
You might also like...
A hacky PHP script to download posts, images, videos and framework grading from Parent Zone

ParentZoneDownloader A hacky PHP script to download posts, images, videos and framework grading from Parent Zone Pre-Requisites Tested on PHP 7.4, but

Easy Repository pattern for PHP Phalcon framework.

Phalcon Repositories Introduction Phalcon Repositories lets you easily build repositories for your Phalcon models, for both SQL and Mongo drivers. PHP

Incubator adapters/functionality for the Phalcon PHP Framework

Phalcon Incubator This is a repository to publish/share/experiment with new adapters, prototypes or functionality that can potentially be incorporated

CMS based on Phalcon PHP Framework with modular structure

Yona CMS Yona CMS - open source content management system (CMS). Written in Phalcon PHP Framework (version 3.x supported) Has a convenient modular str

A PHP framework for console artisans
A PHP framework for console artisans

This is a community project and not an official Laravel one Laravel Zero was created by, and is maintained by Nuno Maduro, and is a micro-framework th

This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database.
This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database.

PHP basic template This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database. Running To

Invo - Sample application for the Phalcon PHP Framework

INVO Application Phalcon is a web framework delivered as a C extension providing high performance and lower resource consumption. This is a sample app

Album-o-rama - Sample application for the Phalcon PHP Framework.

Album O'Rama Phalcon PHP is a web framework delivered as a C extension providing high performance and lower resource consumption. This is a sample app

Sample application to bookmark links, where interface build with Angular.js + Twitter Bootstrap and server powered by PHP with Slim Framework

RESTful Bookmarks PHP Slim TODO: review and update FrontEnd Sample application to bookmark links, where interface build with Angular.js + Twitter Boot

Comments
  • Short, Simple way but how to login?

    Short, Simple way but how to login?

    This is seriously short and simple framework. I am developing a CMS-like project. Could you guide me how to login as admin ? Do I have to make form request and where to put authentication code?

    opened by manishlok 2
Owner
Stephen Damian - Laravel Developer
PHP & React JS Developer - Laravel Expert
Stephen Damian - Laravel Developer
🧬 Nano is a zero-config, no skeleton, minimal Hyperf distribution that allows you to quickly build a Hyperf application with just a single PHP file.

Nano is a zero-config, no skeleton, minimal Hyperf distribution that allows you to quickly build a Hyperf application with just a single PHP file.

Hyperf 273 Jan 4, 2023
It is a simple blog application coded with PHP, HTML, CSS. You can develop, edit. You can see it as a skeleton. ⚡

PHP-BLOG-SYSTEM Simple blog system Features Adding Text Update Text Text Deletion User Login and register Bootstrap Design Profile Page How to use blo

Selçuk 2 Aug 21, 2022
Magento2 Deployment with Deployer (Skeleton)

MageDeploy2 Base Magento2 Deployment Setup using Robo and Deployer. This is the base project you should base your deployments on. It provides an confi

Matthias Walter 44 Jul 18, 2022
The XP Framework is an all-purpose, object oriented PHP framework.

XP Framework Core This is the XP Framework's development checkout. Installation If you just want to use the XP Framework, grab a release using compose

XP-Framework 17 Dec 14, 2022
A panel created based on the Zend Framework MVC framework

?? Painel MyZap2.0 Com ZendFramework 3 Descrição Esse é um painel criado como estudo pessoal do framework (Zend Framework MVC) não foi criado para fin

Jonathan Henrique 9 Jun 10, 2022
A PHP 5.3+ and PHP 7.3 framework for OpenGraph Protocol

Opengraph Test with Atoum cd Opengraph/ curl -s https://getcomposer.org/installer | php php composer.phar install --dev ./vendor/atoum/atoum/bin/atoum

Axel Etcheverry 89 Dec 27, 2022
A framework agnostic PHP library to build chat bots

BotMan If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course. About BotMa

BotMan 5.8k Jan 1, 2023
A framework agnostic, multi-gateway payment processing library for PHP 5.6+

Omnipay An easy to use, consistent payment processing library for PHP Omnipay is a payment processing library for PHP. It has been designed based on i

The League of Extraordinary Packages 5.7k Dec 30, 2022
Simple custom chat bot developing framework for telegram, qq and more in PHP (the best language)

RinoBot RinoBot 是一个为统一聊天机器人扩展开发的框架,编写一份插件用于多种机器人协议。 简体中文 | English ?? 开发中 ?? 暂不适用于生产环境 特性 插件扩展机制 一份代码运行于多平台多协议机器人 并减小开发难度 插件提供 Yaml 配置 供使用者修改 基于机器人 We

LixWorth 3 Apr 18, 2022
A lightweight framework-agnostic library in pure PHP for part-of-speech tagging

N-ai php pos tagger A lightweight framework-agnostic library in pure PHP for part-of-speech tagging. Can be used for chatbots, personal assistants, ke

Giorgio Rey 8 Nov 8, 2022