We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24092
    • 17 Posts
    Thanks for your help guys,

    if I get this sorted I’m going to put into a Doc for other newbies like myself!

    I found how to reverse engineer an existing database and generate a schema in the docs http://svn.modxcms.com/docs/display/xPDO20/xPDOGenerator.writeSchema :

    # $xpdo= new xPDO(’mysql:host=localhost;dbname=myolddatabase’,’username’,’password’,’mydb_’);
    # $manager= $xpdo->getManager();
    # $generator= $manager->getGenerator();
    #
    # $xml= $generator->writeSchema(’/path/to/my/new/packagename.schema.xml’,’mypackage’, ’xPDOObject’,’mydb_’);


    Let’s face it most Php web apps are just about CRUD operations on a database - you’d think that by now that this stuff would almost be automated or you’d be able to buy some sort of GUI that mapped right from your HTML forms through to your database and handled the code generation using an MVC design pattern, DAOs, Value Objects and Logic Classes etc. I’ve looked at most Php code generators out there but they seem to be aimed at people who "don’t even have to program a single line of code" - and they seem to generate very procedural code too - not fully OO and not easily integratable into exisiting code.

    I’m from a Java background myself and have been surprised with Php that the equivalent of things like the Spring Framework, Hibernate etc have not yet been fully embraced by the Php community - or am I wrong?? Like there’s no defacto standard for ORM?

    Thanks

    Peter





      • 9207 ☆ A M B ☆
      • 2,475 Posts
      The documentation needs some more detailed examples, but MODx/xPDO offers as much code generation as you’re going to find out there in my opinion. Symfony and CakePHP will build out model classes from database tables and/or config files, but I don’t know of any PHP code generators that can be used more plug-and-play than what you’d get from those or from xPDO. Java has some nice features to be sure, but there’s also stuff that wouldn’t be good to emulate... Spring and Hibernate are very heavy, and those types of structures just fail when PHP has to load up all libraries for each page load.
        • 4971
        • 964 Posts
        Probably QCodo and its fork QCubed offered more complete code generation
        for PHP but it is heavier than xPDO and has a tougher learning curve...
        and of course, no MODx!!!
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 32674
          • 101 Posts
          Also, I just found that Shawn Wilkerson has some good additional full sample xPDO dox, including schema generation code on his site here:
          http://www.shawnwilkerson.com/code/xpdo/