PHP & MySQL code generation from UML - php

Is there an Eclipse plug-in that will allow me to graphically generate a data model, and produce from it a MySQL Database Script for generation of that database, and generate PHP code for simple add/change/delete methods?
This way I can focus on programming the business logic, instead of fussing with the details of the SQL code.

You should use what is called a framework or ORM. Kohana is a good one, as is codeIgniter, and Doctrine. You can specify your data models in one location and have the DB and code generated. I'm not sure about generating it from a UML model tho.

You can use this UMLtoPHP online generation service that can take as input a UML Eclipse class diagram and generate the corresponding doctrine file for you. With that you can easily generate a full CRUD php application using, for instance, symfony

Related

PHP to UML class Diagrams

Just wanted to know if there is any way i can create class Diagram from PHP code. I have PHP code
accepting POST data from Android(HTTP ) and storing that Data in a MySql database.how do i represent it, i created a class diagram of my android code using ObjectAid plugin for Eclipse. but cannot figure out how to represent PHPMYSql in a class diagram. Tried Enterprise Architect , Didn't work for me.
Thanks..
I'm looking for this as well. In my search I did find phuml.
https://github.com/jakobwesthoff/phuml
It is currently not being developed on and I am unsure on how good the results are (the test I've run is on a codebase that is quite large and that I do not know myself).
However, it is quite easy to work with.
Requires graphviz installed.
apt-get graphviz if you're on linux.
The bad part of it is that you get the UML as img, or pdf. If you generate a PDF it is searchable, but I still haven't figured out a way to make it editable as UML in any uml diagram application.
Supported file formats to export to: http://www.graphviz.org/doc/info/output.html
The set of tools (and their capabilities) that can do this automagically for you is limited. UML models are usually created manually, before a code is written.
From the UML perspective there is no difference between PHP Object-Oriented code and Android Object-Oriented code and MySQL tables are just classes without operations.
Although you may be lucky in partially automating the model creation through reverse-engineering, to make it readable and emphasize parts that are important through diagrams with different level of detail, you'll have to involve a manual work.
For an overview of what can UML do for you, walk through Kirill Fakhroutdinov's online book uml-diagrams.org: UML Diagrams Examples

Simple CRUD Generation

This is what I have:
An entity-relational schema, modelled for Doctrine 2.0 (in PHP);
The generated database, on a MySQL server.
This is what I want:
A very basic CRUD web-interface to the database, that allows me to (you guessed it!) create, read, update and delete records, with extra credit for implementing CRUD operations on entities and relations instead of records.
Now, I'm terrible at writing web applications myself (read: I'm lazy). Are there any options to generate a CRUD web application from a MySQL database, or from a set of Doctrine entities?
I'd be willing to stop using PHP (and thus rewrite the entities for JPA, Ruby ActiveRecord, etc...) but not MySQL.
I see a lot of similar questions: however, most of these questions have answers that give CRUD operations for in PHP code, or recommend using Doctrine.
An answer such as "There is no such tool, stop being lazy" would also be appreciated.
You should have a look at Grocery CRUD.
Really simple, easy to use /deploy and neat UI.
http://www.web-and-development.com/grocery_crud/
I did a complete web CRUD of my DB in a couple of hours (including additional PHP webservices) Amazing :-)
Symfony does this (at least the 1.x series I am used to). I should think version 2.0 also does, under either Doctrine or Propel (and both of those will work with MySQL).
CakePHP (user guide) takes a database model and generates controllers that do basic CRUD operations for all of your tables. It also includes views and a basic stylesheet.
If your hosting setup can handle Python, the web2py framework offers instant CRUD for a database and a very user friendly (and laziness-friendly) online dev environment. I don't think it's designed to be laid overtop of an existing database, but you can import a CSV file with your database contents. http://www.web2py.com
One of the great things about web2py is that creating custom (public) CRUD pages is also dead easy. In a controller file it's as easy as
form = CRUD.create(db.myTable)
return dict(form = form)
Then in a view file you just add
{{=form}}
And that's it! All of the form creation, input validation, etc., is handled for you. I should also add that the data abstraction layer in web2py is very easy to learn and meshes with mySQL easily. One great thing about it is that web2py performs on-the-fly changes to your datastructure or even migrations from one DB back-end to another.
Not every hosting company knows how to support web2py, but it's easy to deploy on the Google App Engine or with a company like Fluxflex.com
I've been looking for a drop-in admin panel like this too, so far I've 3:
AjaxCrud - http://ajaxcrud.com/
Peek from Code Canyon - http://bit.ly/toKKrB
SQLBuddy - http://www.sqlbuddy.com/
Love to hear any other suggestions!
Ruby on Rails' "Scaffolding" should be exactly what you're looking for...
As according to this answer, I've tried Xataface, which gave me as decent a result as CakePHP or Web2Py would have given me. Am now trying Symfony 2.0 (which is a lot harder then I'd have expected) for the extra credit.

program/site to generate html form code based on mysql database

I have a mysql databased with many tables and fields. I would like to quickly generate a set of prototype forms based on the mysql database (or create table statements). Anyone have any suggestions? html form code would be great. Full PHP validation and insert updates would be even better. Also Zend framework code would be ideal.
I was looking at mySQL workbench which has an excelent reverse engineering and visual presentaion of databases, but no form generator.
You're looking for a thing called scaffolding.
Scaffolding is a meta-programming method of building database-backed software applications. It is a technique supported by some model-view-controller frameworks, in which the programmer may write a specification that describes how the application database may be used. The compiler uses this specification to generate code that the application can use to create, read, update and delete database entries, effectively treating the template as a "scaffold" on which to build a more powerful application.
Please note that ZF and other PHP frameworks are not MVC frameworks - at least those popular like ZF, Symfony, Kohana, CakePHP etc.
It seems that ZF has built-in support for scaffolding: Zend_Controller_Front_Scaffold.
well, what you want is a little too much specific (not saying that it doesn't exist). maybe this could help you with the boring task of writing the html tags:
http://code.google.com/p/zen-coding/

Is there any php framework which exactly reflect the msaccess

I am fond of dbstructure definition of msaccess which lets defining at once and creating the data entry forms, datatables and reports at once easily.
I have been searching for some framework which would generate the data entry forms, data tables and reports easily. I guess the only thing I need to define is complete datatable structure.
Is there any like that or better one than that?
EDIT:
well i am afraid that PHP frameworks have been limited to programmers only. I would like to extend it with some automated functions like autoform in msaccess which would generate data entry form, auto report for data listing. So that my development time would be again some less. I found doctrine nearly matching my specification but not sure as i haven't fully explored doctrine
Cake offers both "hard" (bake) and "soft" scaffolding, which should be very close to what you want. It's still only meant as a quick proof-of-concept tool and to get you up and running faster so you can concentrate on programming the business logic. It's not meant as a hands-off solution nor to be used in production.
What you seem to be looking for is a database frontend like phpMyAdmin or SQL Buddy, not a PHP framework.
Symfony provides an admin generator that builds all the forms on the fly and it will also update itself when you change your db schema. It is based on doctrine which you say you looked at so that would make things a bit easier for you.

Is there a tool or script that generates database out of PHP models?

Is there a tool or script that generates and syncs database out of PHP models, just the way like Django does it for Python?
I'm aware of tools that generate databases out of XML, YAML, etc... I don't want it. I want to write production code on PHP, describing models, then run "syncdb" and get the database, that is ready to work with described models.
I remember playing with http://redbeanphp.com/ a while ago. You'd create your classes in PHP, add relationships to them via class variables, and it would take care of creating the database and keeping it updated.
There is no such thing as "PHP Models". There are various ways to describe a database model, but none of them are standardized, so it's not possible for such tool to exist.
There are, however, tools that generate database tables out of models in some frameworks. However, those are specific to the framework's models (usually written in xml or yaml, by the way).
And anyway, database design is usually a more complicated issue than just "making it work with models", so unless you have a rather verbose model (describing indexes, data types, relations etc.), a tool automatically generating tables wouldn't be useful in production.
Yii framework has something similar, called Gii. It auto generates other stuff too and you can add your own custom generators.
More info here: http://www.yiiframework.com/doc/guide/topics.gii

Categories