PHPackages                             djamp/djamp - 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. djamp/djamp

ActiveProject[Framework](/categories/framework)

djamp/djamp
===========

framework MVC baseado no SlimFramework

v2.2(5y ago)011[2 PRs](https://github.com/dandico23/DjampMVC/pulls)MITJavaScript

Since Feb 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dandico23/DjampMVC)[ Packagist](https://packagist.org/packages/djamp/djamp)[ RSS](/packages/djamp-djamp/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (5)Versions (13)Used By (0)

Djamp - Framework MVC
=====================

[](#djamp---framework-mvc)

[![Quality Gate Status](https://camo.githubusercontent.com/90e9433fdbfc90086489d1b92dbd8309d16b8289813d519d2b44d0de066f6dba/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d64616e6469636f32335f446a616d704d5643266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=dandico23_DjampMVC)[![Build Status](https://camo.githubusercontent.com/3e3eee1e9a9750c205106fa0bef757b63d8016a3ea01eeac721d8aa546a73de4/68747470733a2f2f7472617669732d63692e636f6d2f64616e6469636f32332f446a616d704d56432e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/dandico23/DjampMVC)[![Maintainability](https://camo.githubusercontent.com/8da3564e17378637443150bd3df771ae9fe3d004b866cdf850f4ae688fd5bade/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66613830393964663338643564336634623566312f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/dandico23/DjampMVC/maintainability)[![Total Downloads](https://camo.githubusercontent.com/62aebe001d3abf0716b7b195c5275501fbba83f5a7cd8a02e1f7e670e83b5bae/68747470733a2f2f706f7365722e707567782e6f72672f646a616d702f646a616d702f642f746f74616c2e737667)](https://packagist.org/packages/djamp/djamp)[![Latest Stable Version](https://camo.githubusercontent.com/011cdc8aacf9ad1f3b3bca61f5a2e1335b390d55fb1f141d0744e99409be153f/68747470733a2f2f706f7365722e707567782e6f72672f646a616d702f646a616d702f762f737461626c652e737667)](https://packagist.org/packages/djamp/djamp)[![License](https://camo.githubusercontent.com/eda120d966d1097b115f6b1280285971629002723c82257c4b817045c4e09028/68747470733a2f2f706f7365722e707567782e6f72672f646a616d702f646a616d702f6c6963656e73652e737667)](https://packagist.org/packages/djamp/djamp)

Framework MVC desenhado para aplicações que tenham multiplas fontes de dados(databases, APis) e multiplos ambientes(produção, desenvolvimento, homologação, treinamento). utiliza Twig como engine de templates, Flash para mensagens entre requisições.

### Requisitos

[](#requisitos)

- PHP 7.3.12
- PHP-CLI
- pdo\_pgsql(extensão php)
- pdo-oci(extensão php)
- Composer

### Bancos de dados compativeis

[](#bancos-de-dados-compativeis)

- Oracle
- Postgres
- Mysql

### Instalação Rápida

[](#instalação-rápida)

```
composer create-project djamp/djamp

```

### Criando classes automaticamente

[](#criando-classes-automaticamente)

Se o PHP-CLI estiver instalado é possivel usar a linha de comando para criar novas classes para o seu projeto

#### Criando uma class Controller

[](#criando-uma-class-controller)

```
php djamp create:Controller ExemploController

```

#### Criando uma class Model

[](#criando-uma-class-model)

```
php djamp create:Model ExemploModel

```

### Mapeando os ambientes

[](#mapeando-os-ambientes)

O Djamp mapeia as fontes de dados conforme parametros definidos na URI. Exemplo:

O domino principal da sua aplicação é: exemplo.com.br

Você definiu que os ambientes da aplicação serão os seguintes:

exemplo.com.br - ambiente de produção
exemplo.com.br/desenvolvimento- - ambiente de desenvolvimento
exemplo.com.br/homologacao - ambiente de homologação
exemplo.com.br/treinamento - ambiente de treinamento

Esse seria o seu arquivo Config/state.ini:

```
homolog = homologacao
develop = desenvolvimento
training = treinamento

```

### Declarar uma Model

[](#declarar-uma-model)

```
$examplesModel = $this->loadModel('Examples');

```

O nome do arquivo de Model deve ser, para esse caso, ExamplesModel.

### Estabelecimento de conexão com banco de dados

[](#estabelecimento-de-conexão-com-banco-de-dados)

Dentro de algum arquivo de model:

```
$this->initDatabase("banco_mysql");

```

O nome\_da\_database deve ser declarado no arquivo database.ini, antecedido pelo ambiente. Por exemplo, para declarar um banco chamado banco\_mysql que é usado em ambiente de produção, a declaração deve ser feita da seguinte forma:

```
[default_banco_mysql]
  host=127.0.0.1
  port=3308
  type=mysql
  dbname=test_db
  user=root
  password=
  scheme=

```

### Chamada de funções do banco de dados

[](#chamada-de-funções-do-banco-de-dados)

A classe MyPDO implementa as funções de CRUD e paginação. Todos os models criados herdam essa classe e podem realizar as queries de forma simplificada. A seguir são demonstrados exemplos para a chamada de cada operação.

#### Insert

[](#insert)

Recebe como argumento o nome da tabela e os valores das colunas a serem inseridos em forma de array:

```
$values = array("column1" => "value1", "column2" => "value2", ...);
$inserted_element = $this->container["database_name"]->insert('table_name', $values);

```

#### Select

[](#select)

Recebe como argumento a query sql a ser executada:

```
$sql = "SELECT * FROM table_name WHERE column1 = 'value1'";
$result_elements = $this->container["database_name"]->select($sql);

```

#### Update

[](#update)

Recebe como argumento os valores a serem atualizados em formato de array. Como argumento opcional, podem ser passados filtros para os elementos a serem atualizados, caso contrário, todos os elementos sofrem alteração:

```
# Update Sem filtros
$values = array("column1" => "updated");
$number_of_updated = $this->container["database_name"]->update('table_name', $values);

# Update Com filtros
$values = array("column1" => "updated");
$where = array("Column1" => 'filtro');
$number_of_updated = $this->container["database_name"]->update('table_name', $values, $where);

```

#### Delete

[](#delete)

Recebe como argumento a query sql a ser executada:

```
$sql = "DELETE * FROM table_name WHERE column1 = 'value1'";
$number_of_deleted = $this->container["database_name"]->delete($sql);

```

#### Paginate

[](#paginate)

Existem duas funções responsáveis por realizar a paginação. A primeira delas recebe como argumento o nome da tabela e o número de elementos por página e tem como retorno as seguintes variáveis:

- total\_pages: número total de páginas
- first\_page: lista com os elementos da primeira página
- cipher\_text: identificador usado para requisitar demais páginas
- iv: identificador usado para requisitar demais páginas

As variáveis cipher\_text e iv são argumentos para a função que retorna as páginas seguintes da tabela.

```
# Get first page
$elements_per_page = 5;
$result_array = $this->container["database_name"]->paginateGetTotalPages('table_name', $elements_per_page);
$first_page = $result_array['first_page'];
$total_pages = $result_array['total_pages'];
$cipher_text = $result_array['cipher_text'];
$iv = $result_array['iv'];

# Get second page
$page = 2;
$second_page = $this->container["database_name"]->selectPaginate($cipher_text, $iv, $page);

```

### Validação

[](#validação)

A biblioteca Validator implementa diversas validações que podem ser acessadas da seguinte forma nos models e controllers:

```
$valid_result = $this->validator->validate($data, $rules);

```

As variáveis $data e $rules devem ser arrays contendo, respectivamente, os campos a serem validados e as regras de validação. Múltiplas regras podem ser passados, se separados por '|'. Exemplo:

```
$data = [
    'email' => 'daniel@mail.com',
    'age' => 2,
    'expire_date' => 'tomorrow',
    'punctuation' => 10,
    'color' => 'blue',
    'phone' => '34358525'
];
$rules = [
    'email' => 'required|email',
    'age' => 'required|numeric',
    'expire_date' => 'date|after:now',
    'punctuation' => 'numeric|between:1,11|different:4,5',
    'color' => 'string|in:red,green,blue',
    'phone' => 'size:8'
];

```

As seguintes validações estão disponíveis:

- required - field must exist in $data
- email - field must be in mail format
- numeric - field must be a number
- accepted - The field under validation must be yes, on, 1, or true
- after:date - The field under validation must be a value after a given date. The dates will be passed into the strtotime PHP function
- after\_or\_equal:date - Similar to after, but considering equal
- before:date - Similar to previous 2 arguments
- alpha - The field under validation must be entirely alphabetic characters.
- alpha\_numeric - The field under validation may have alpha-numeric characters
- between:min,max - The field under validation must have a size between the given min and max (equal not included). Strings and arrays are evaluated based in size
- boolean - The field under validation must be able to be cast as a boolean. Accepted input are true, false, 1, 0, "1", and "0".
- date - The field under validation must be a valid date according to the strtotime PHP function
- date\_equals:date - The field under validation must be equal to the given date The dates will be passed into the PHP strtotime function.
- date\_format:format - The field under validation must match the given format, function \\DateTime::createFromFormat is used
- different:field1,field2 - The field under validation must have a different value than given fields.
- digits:value - The field under validation must be numeric and must have an exact length of value.
- digits\_between:min,max - The field under validation must have a length between the given min and max (equal not included).
- in:foo,bar - The field under validation must be included in the given list of values
- not\_in:foo,bar - The field under validation must not be included in the given list of values
- integer - The field under validation must be an integer
- string - The field under validation must be a string
- max:value - must be less than or equal a maximum value. Strings and arrays are evaluated based in size
- min:value - must be higher than or equal a minimum value. Strings and arrays are evaluated based in size
- regex:pattern - The field under validation must match the given regular expression.
- size:value - The field under validation must have a size matching the given value, represented by the number of chars if integer or string and the count function for arrays

### Exemplos

[](#exemplos)

Por meio de rotas já definidas, é possível realizar o teste das funções de acesso a um banco de dados mysql local. Para isso, os seguintes passos devem ser realizados:

- Instalar um banco mysql local
- Editar o campo 'default\_mysql\_test' no arquivo 'database.ini' para realizar o apontamento correto ao banco local
- Criar uma database chamada 'test\_db' (ou criar com qualquer outro nome e alterar em database.ini)
- Criar uma tabela chamada 'test\_table' com uma coluna de chave primária e as seguintes colunas: 'column1', 'column2', 'column3'

Feitos os passos descritos acima, as funções CRUD podem ser utilizadas por meio das seguintes rotas:

/examples/insert
/examples/select
/examples/update
/examples/delete
/examples/paginate /examples/validate (não necessária a configuração de banco de dados)

O código desses exemplos pode ser encontrado nos arquivos ExamplesController e ExamplesModel.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

4

Last Release

1955d ago

Major Versions

v1.2 → v2.02020-02-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32055500?v=4)[dandico](/maintainers/dandico)[@Dandico](https://github.com/Dandico)

---

Top Contributors

[![dandico23](https://avatars.githubusercontent.com/u/38084434?v=4)](https://github.com/dandico23 "dandico23 (20 commits)")[![Daniel-Goncalves](https://avatars.githubusercontent.com/u/27386944?v=4)](https://github.com/Daniel-Goncalves "Daniel-Goncalves (17 commits)")[![ArthurLenzi](https://avatars.githubusercontent.com/u/26462248?v=4)](https://github.com/ArthurLenzi "ArthurLenzi (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/symfony-demo

Symfony Demo Application

2.6k254.2k](/packages/symfony-symfony-demo)[phlak/directory-lister

PHP directory lister

2.5k1.4k](/packages/phlak-directory-lister)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1557.6k](/packages/bacula-web-bacula-web)[oat-sa/tao-core

TAO core extension

66143.7k121](/packages/oat-sa-tao-core)[duxweb/dux-lite

The lightweight framework based on slim php

161.0k9](/packages/duxweb-dux-lite)

PHPackages © 2026

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