PHPackages                             cuculcan/core - 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. cuculcan/core

ActiveProject[Framework](/categories/framework)

cuculcan/core
=============

tiny php framework

0.5.1(6y ago)09[1 PRs](https://github.com/Cuculcan/core/pulls)MITPHPCI passing

Since Jun 16Pushed 3mo agoCompare

[ Source](https://github.com/Cuculcan/core)[ Packagist](https://packagist.org/packages/cuculcan/core)[ RSS](/packages/cuculcan-core/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

CORE
====

[](#core)

Small simple PHP MVC RESTlike framework for training purposes

installation
------------

[](#installation)

```
composer create-project cuculcan/core
```

Navigation
----------

[](#navigation)

[Model](#Model)

[Controller](#controllers)

[View](#views)

### Model

[](#model)

Models are objects inherited from the Entity class. The entity corresponds to the row in the database table

each entry has at least an "id" field

User class example:

```
class User extends Entity {

    public $name;
    public $email;
    public $cityId;
    public $login;
    public $password;

    /**
     * @type = json
     */
    public $subscription;

    /**
     * @extra
     */
    public $city_name;

    /**
     * @extra
     */
    public $region_name;

    public function __construct(array $data = []) {
        parent::__construct($data);
    }

}
```

Entity fields can be annotated.

***extra*** means that this property has no relation to the table column

***type = json*** used to pack arrays in json when saving to db

***default\_value =*** used to set the default value in case the value is undefined

the constructor should be described as in the example and have at least the data parameter used to build the object after selecting from the database

### Storages

[](#storages)

For entities, storage objects are created that implement the functionality for working with the Database Repositories inherit from the MysqlStorage base class

СRUD methods for the Entity object are implemented in the base class MysqlStorage

```
class UsersMysqlStorage extends MysqlStorage {

    /**
     *
     * @param \Pdo $connection
     */
    public function __construct($connection) {
        parent::__construct($connection, 'users'); //Sets the name of the table with which the storage works
    }

    /**
     * uses the parent class method getById
     * @param int $id
     * @return User
     */
    public function getById($id) {
        $data = parent::getById($id);

        if (!$data || $data === null) {
            return null;
        }

        return new User($data);
    }

     /**
     * direct query can be implemented using \PDO
     * @return int
     */
    public function countUsers() {
        $sql = " SELECT count(id) AS cnt FROM users ";

        $stm = $this->connection->prepare($sql);
        $stm->execute();
        $cnt = 0;
        while ($row = $stm->fetch(\PDO::FETCH_ASSOC)) {
            $cnt = $row['cnt'];
        }
        return $cnt;
    }
}
```

Controllers
-----------

[](#controllers)

Controllers are designed to handle incoming requests

Any request to the site is converted using .htaccess RewriteRule

```
RewriteRule ^(.*)$ index.php?handler=$1 [QSA,L]

```

or nginx rewrite

```
location @rewrite {
    rewrite ^/(.*)$ /index.php?handler=/$1;
}
```

and sent to index.php

The sequence of request processing is as follows:

```
.htaccess->index.php->Request->Router->Controller

```

Controller Inheritance Chain

```
AController
    ^
    |
BaseController
    ^
    |
MainController and other controllers

```

**AController** is abstract. Invokes methods for handling addresses described in specific controllers. Should not depend on a specific project

**BaseController** inherits from AController and contains common methods for all user controllers. For example, initialization of a session user. Preparing data for menus and others.

***MainController and other user controllers*** are inherited from BaseController and contain methods for processing specific url addresses. The project must have at least one controller named **MainController**, it is responsible for processing calls to the root of the site.

```
http://mysite.com

```

To process other requests to the site, request handlers must be described in the appropriate controllers. For example, addresses starting with:

```
http://mysite.com/user

```

Must be described in UserController

### Routing

[](#routing)

Each controller class must have a method implementation

```
protected function setActions()
```

Handlers of URL templates are registered inside. There are handlers for ***GET, POST, PUT, DELETE*** requests. Implemented as Methods with appropriate names

```
get()
post()
del()
put()
```

The URL template handler has the format

```
$this->get | post | del | put ('[url pattern]', callback function with parameter ($urlParams));
```

The implementation of the response to the request is described in the callback of this method. In the URL template, there may be a variable parameter which is written in curly brackets and may be available inside the callback

```
$this->get('/user/{userId}/get_name', function ($urlParams)  {
    echo $urlParams['userId'];
});
```

In this example, a request of the form ***http: //myexample.com/user/12345/get\_name*** will be processed and ***12345*** will be displayed

**Request parameters** can be accessed through the request object and it methods

getQueryParameters() - will return an array of parameters

getQueryParameter($name, $default = null) - will return the value of the parameter or the value passed to default, if the parameter is missing

```
 //process GET request http://myexample.com/user/set_name?name=VasiliyPupkin
$this->get('/user/set_name', function ($urlParams)  {

   $name =$this->request->getQueryParameter("name", "");
   echo $name
});
```

All methods described in setActions() are executed in turn and the one that matches the template is selected, if more than one method matches the pattern, an exception is thrown

In all objects of the controller, the variable ***model*** is present. It is used to transfer data to objects of the View class for later display.

The View object is called by the method $ this-&gt;showView("UserView"). The parameter is the name of the class to display.

```
//process GET request http://myexample.com/user
$this->get('/user', function ($urlParams)  {

   $this->model['some_parameter'] = 'param from user controller';
   $this->showView("UserView");
});
```

View will be displayed with the class UserView

View
----

[](#view)

View classes inherit from the abstract class AView, used to display templates. PHP itself is used as a template engine.

MainView class example:

```
class MainView extends AView
{
    public function __construct($model) {
        parent::__construct();
        $this->model = $model;
    }

    protected function setTemplateName()
    {
        /*
        * the template name is set relative to the path specified in config/config.php
        */
        $this->templateName = '/main.php';
    }

    //--------------------------------- SEO --------------------------------
    protected function setTitle(){
        $this->title = "";
    }

    protected function setKeywords()    {
        $this->keywords="";
    }

    protected function setDescription(){
        $this->description="";
    }
    //---------------------------------------------------------------------------
    protected function setAdditionalCSS(){
        array_push($this->additionalCSS, '/css/main.css');

    }

    protected function setAdditionalJS(){
        array_push($this->additionalJS, '/js/main.js');
    }

    protected function setCustomHeaders(){
        array_push($this->customHeaders, "MY-PEW-HEADER: pew-pew-pew");
    }

}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance54

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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 ~808 days

Total

2

Last Release

2441d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8de7528532ad74fd7f1bc72fe2e322f3a828da737b496262d187c879246c177c?d=identicon)[Cuculcan](/maintainers/Cuculcan)

---

Top Contributors

[![Cuculcan](https://avatars.githubusercontent.com/u/25888559?v=4)](https://github.com/Cuculcan "Cuculcan (2 commits)")

---

Tags

easyframeworkphprestapi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cuculcan-core/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[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.7M255](/packages/laravel-dusk)[laravel/prompts

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

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

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

PHPackages © 2026

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