Professional Documents
Culture Documents
Devups Tuto Make A Crud
Devups Tuto Make A Crud
5 CRUD
Do your best
AZANKANG ATEMKENG
SPACEKOLA
Devups 4.5 CRUD
AZANKANG ATEMKENG 1
Devups 4.5 CRUD
Introduction
Hi everybody so here is my first tutorial and it talks about Devups, a php framework I wrote and hope
you will like
I. Base structure
Ok now let’s enter the folder src at the root of the project. The elements of this folder are called
component and component itself contain module. we call this two level modularity.
By default, a project devups comes with devups component who contains the module admin we saw
early in the browser.
controller
core
entity
form
component module js
architecture src ressource
requires.php views entity
index.php
moduledependences.php
services.php
II. Data-core
Before doing something let’s introdious the main concept of devups datacore
Devups framework has this that it can generate code source (crud) of entities base on your uml diagram
model. That can be easyly integrate on the project in process. And to do that devups use a structured
dataset that transcript all the uml class diagram, and that file’s name is datacore.
Data-core are JSON file who define the model of an element. Those elements can be entity (from uml
class diagram), module (group of entities) or component (group of modules) and help devups generate
code source and structure folder for each type of element.
AZANKANG ATEMKENG 2
Devups 4.5 CRUD
- entityCore define the entity with relation. They are found in Core folder in module (ex:
src/devups/ModuleAdmin/Core/dvups_adminCore.json)
- moduleCore: define the module with its entities. They’re found on every module root (ex:
src/devups/ModuleAdmin/moduleadminCore.json)
- componentCore: define the component with its modules. Found on component root. (ex:
src/devups/devupsCore.json)
at the root of “src” folder let’s create “devupstuto” folder, we will call it devupstuto component, then,
inside the devupstuto component, create devupstutoCore.json and let write the minimum component.
{
"name": "devupstuto",
"template": "adminv2",
"listmodule": [
{
"name": "ModuleStock",
"project": " devupstuto",
"listentity": [
{
"name": "storage",
"attribut": [
{
"name": "id",
"datatype": "integer",
"nullable": "not",
"formtype": "text"
},
{
"name": "name",
"datatype": "string",
"size": "255",
"nullable": "not",
"formtype": "text"
}
],
"relation": []
}
]
}
]
}
AZANKANG ATEMKENG 3
Devups 4.5 CRUD
Components are the element who contains the logic of a project. We then distinguish two type of
component:
- main component who representing the logic of the current project your are building and
- component comes from other project. To either complete or just add some new logic to your
main component.
For this minimum component we want to build the entity: storage, contain in the module: ModuleStock
contain in devupstuto component
Figure 2 core:g:component
It has the same structure as the module admin in devups component we saw early. You can visit file
generated it looks really sexy :D.
A. Add dependences
before continue, there is something we have to do for the module to be use.
On the root of the src, edit the file requires.php then, just require your module dependence like this:
require “devupstuto/ModuleStock/devupstuto.modulestock.php”;
AZANKANG ATEMKENG 4
Devups 4.5 CRUD
You have to require each new module you create here for it to be use in all the project, a part the
module admin dependence.
B. Update admin
Ok let’s execute some command:
php devups dvups_:update
Figure 4 dvups_:update
This command add the new module and entities in the data base and update the master admin privilege.
Once all’s done, go to the browser, logout then login again and you will see the module appear in the
back-office.
AZANKANG ATEMKENG 5
Devups 4.5 CRUD
Why?
Because all we’ve done with the command, is update the data of devups component (dvups_module,
dvups_entity and dvups_admin) but the database schema has not changed to integrate the new entity:
storage. To update the database schema, we will use doctrine.
note: the purpose of doctrine in devups framework is to update database schema, nothing else.
This command will show you the query that will be execute.
Then:
AZANKANG ATEMKENG 6
Devups 4.5 CRUD
B. Test crud
Now, just refresh the page and you can now make crud operation on the entity in the new module.
AZANKANG ATEMKENG 7
Devups 4.5 CRUD
AZANKANG ATEMKENG 8
Devups 4.5 CRUD
AZANKANG ATEMKENG 9
Devups 4.5 CRUD
Ok back to the code and let’s see how all this works.
AZANKANG ATEMKENG 10