Generate models from Database with webtools¶
In this part, your project is already created.
If you do not have a mysql database on hand, you can download this one:
Check the database configuration with webtools at
Go to models part:
The configuration file is located in app/config/config.php
Change the configuration of the database to use the messagerie database:
- Click on the Edit config file button
- Select the database part
- Enter messagerie in the dbName field
- Click on Test button to check the connection
- Validate with the Save configuration button
To generate all models, click on (Re-)create all models button.
Generate the models cache by clicking on Re-init all models cache button:
The models are generated and operational.
You can now see datas.
It is possible to generate models automatically when creating a project with the
-m option for models and
-b to specify the database:
Ubiquity new quick-start -a -m -b=messagerie
Still in the models part, click on the models generation step:
Then click on Classes diagram button:
You can see the class diagram, using the yUML API
To see the metadatas of a created model:
Select a model, and activate the Structure tab:
You can also view the partial class diagram:
The third tab gives information about object validation:
The validation rules were generated automatically with the classes.
They are defined through
@validator annotations on each member of a class and are stored in cache.
The Validate instances button is used to check the validity of the instances:
It is normal that by default all instances in the database do not check all validation rules.
Generated classes are located in app/models folder, if the configuration of mvcNS.models has not been changed.
If you want to know more about:
The Settings class:
Any modification on the classes (code or annotations) requires the reset of the cache to be taken into account.
Ubiquity init-cache -t=models