News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Turland:
Customizing Codeception Database Cleanup
May 12, 2014 @ 11:15:24

If you're a Codeception user, you'll find Matthew Turland's latest post interesting. In it he shares a way to customize database cleanup between the tests. Codeception handles it a bit differently that how PHPUnit's Db module does.

Recently, I was looking into ways to speed up the runtime of the test suite at Blopboard. We use the Codeception framework to write functional tests for our REST API, part of which entails putting the database into a known state using Codeception's Db module. The behavior of this module is similar to that of the PHPUnit Database extension with one exception: where PHPUnit only truncates tables and leaves their schemas intact, Codeception removes the database structure and expects the SQL dump it uses to recreate it between tests. I must admit to not understanding this design decision of Codeception, nor attempts to clarify it.

He admits that his solution is "a bit hacky" but it does work to truncate the table rather than drop the entire schema and wait for a rebuild. His "DbHelper" class is used in place of the Db module. He traced through the execution path of the Db module and found a "hook" where he could override the "cleanup" method to prevent the schema drop and replace it with a truncate. He also includes code for a suggested addition to Codception that would handle the same thing in a more integrated way.

0 comments voice your opinion now!
customize database cleanup codeception tutorial schema truncate phpunit

Link: http://matthewturland.com/2014/05/09/customizing-codeception-database-cleanup

Chris Jones:
Getting Started with PHP Zend Framework 2 for Oracle DB
May 15, 2013 @ 10:55:41

In his latest post to his site Chris Jones shows you how to update the Zend Framework 2 tutorial app (quickstart) to make it work with an Oracle database instead.

This post shows the changes to the ZF2 tutorial application to allow it to run with Oracle Database 11gR2. [...] The instructions for creating the sample ZF2 application are here. Follow those steps as written, making the substitutions shown [in the rest of the post].

The full schema definition is included in the post, complete with the same sample data as the tutorial. He includes the updates you'll need to make to the database configuration for the OCI8 connection and changes to the code to accommodate the Oracle data format (mostly uppercasing everything).

0 comments voice your opinion now!
zendframework2 tutorial oracle database schema code

Link: https://blogs.oracle.com/opal/entry/getting_started_with_php_zend

Danne Lundqvist's Blog:
Getting to grips with an existing XML structure
April 25, 2012 @ 10:44:43

Danne Lundqvist has a new post where he shares a bit of code he's written to "come to grips" with an existing XML structure.

Very often I find myself writing input filters for large XML files using PHP. Common enough task; and PHP offer a great variety of tools to do this effectively depending on the situation. Unfortunately, almost as common is the lack of documentation for the aforementioned XML files. [...] I have looked around for a simple tool but I didn't really find a tool that gave me the quick and dirty overview I wanted. A year or so ago I finally wrote a small PHP class to analyze large XML files.

He includes an example XML file, the HTML output of the parsing and a sample of how to use the class to parse and output the XML structure, complete with some CSS.

0 comments voice your opinion now!
xml structure schema parse output html csss


Sameer Borate' Blog:
Creating SQL schemas with Doctrine DBAL
December 22, 2010 @ 14:25:53

On his blog today Sameer Borate has a new post looking at using Doctrine DBAL to make schemas rather than having to make them by hand each time (can be very useful for reloads with fixtures).

A tedious task during web development is that of database schema creation. A schema containing a few tables comprising of a small set of rows is quick, while that containing dozens of tables and large numbers of columns is a tedious process. I usually resort to a small php script with some regular expression tossed in to automatically create a schema from a text file definition. But that is a little buggy as I've to manually add the indexes and other small things. Now that Doctrine has released a DBAL library, this will provide a nice ability to automatically create sql schemas.

He introduces the DBAL abstraction layer and includes a basic script to create a schema for a MySQL database, manually adding the columns and setting up things like primary keys and foreign key constraints. He also includes the SQL statements that it will generate and execute on your Doctrine-based connection.

1 comment voice your opinion now!
sql schema doctrine generate dbal mysql


Gonzalo Ayuso's Blog:
Keep our PostgreSQL databases synchronized with PHP. Database version control
December 13, 2010 @ 09:26:49

In this new post to his blog today Gonzalo Ayuso looks at how he's set up a system that uses PHP to synchronize their PostgreSQL databases' schemas when things changed.

We create source code at development server and push the changes to production. It's really easy to keep synchronized all our code. But with databases it's different. [...] It's a recurrent problem working with databases. We create database objects (tables, views, ..) in the development server and when our application is ready to go live we push the changes to production server. If we are smart developers we save all database scripts in a file and when we deploy them to production we execute the script.

He mentions tools like dbdeploy and phing to help make these migrations a bit more automatic. He needed something a little different though - a command-line script that would, based on an ini file, sync two or more databases. He's created the basic script that includes the actions to show the differences between the databases, a summary of the differences and an execution method to bring them into sync. He gives a basic example of how it would handle the sync between his example production and development databases.

0 comments voice your opinion now!
synchronize database schema version control


Rob Allen's Blog:
Akrabat_Db_Schema_Manager Zend Framework database migrations
March 29, 2010 @ 10:16:41

Rob Allen has a new post to his blog today that looks at database migrations in Zend Framework applications. He introduces a component of his own - Akrabat_Db_Schema_Manager - to handle the migrations.

It is intended that any time you want to make a change to your database schema (add columns, tables, indexes, etc), then you create a new migration file. [...] The migration file contains a class that extends Akrabat_Db_Schema_AbstractChange and must contain two methods: up() and down(). It follows that up() is called when implementing the changes in this migration and down() is called to put the database back where it was if the change is backed out.

He includes an example of a migration file, one that defines the "up" method to create a table and the "down" to remove it. The Akrabat_Db_Schema_Manager is what your script would interface with by calling the "updateTo" method and change your database's structure. It can even hook into Zend_Tool to make it command-line friendly.

0 comments voice your opinion now!
zendframework database migration akrabat schema


Chris Hartjes' Blog:
Converting Legacy Apps to CakePHP, Part 2
December 09, 2008 @ 10:26:09

Chris Hartjes has posted the second part of his look at converting legacy applications over to a more structured CakePHP environment. In this new post he looks at working with the database schema.

Now you've decided to convert your legacy app over to CakePHP, you will run into the first serious obstacle: your database schema. To put it bluntly, if your schema does not already account for relationships between multiple tables you are screwed. Given that CakePHP is good at generating the queries you need to pull related records in for you, you NEED that schema to contain relationships.

He talks about the importance of relationships, creating his working models and some things to get well acquainted with - ow relationships work in CakePHP, how to use Containable behavior and some good SQL to back you up should you need it.

0 comments voice your opinion now!
cakephp legacy application convert model database schema


Francois Zaninotto's Blog:
Validating a YAML file against a schema in PHP
September 24, 2008 @ 12:58:35

Francois Zaninotto submitted a tutorial he's written up about creating a YAML validation script with PHP.

As of today, there is no simple way to validate the syntax of a YAML file in PHP. But with two simple tricks, it takes only a few dozens of lines of code to build a robust validator capable of checking the syntax of any YAML file against a given schema.

He points out that Ruby has a tool for this (kwalify) but PHP doesn't. He creates his own with the help of the sfYaml component from the symfony framework, translating the YAML data into something PHP can parse more easily - XML. He passes this through an XSL parser and uses the DOM XML schemaValidate function to check it against the given schema.

0 comments voice your opinion now!
yaml validate tutorial schema xsl domxml sfyaml symfony framework


Padraic Brady's Blog:
ZF Blog Tutorial Addendum #1 Base URL, Magic Quotes, Database Schema & UTF-8
May 29, 2008 @ 16:12:03

Padraic Brady has an addendum he's posted to his "making a blogging application with the Zend Framework" series dealing with a few random issues from along the way.

The interesting thing about live publishing of a long tutorial series is that it's not flawless. In fact it's the opposite. [...] To cover all these I'll occasionally highlight the more important ones both in notes to new entries, or where they slip past me, in Addendum entries like this one.

There's four sections in this update - one dealing with the referencing of base URLs, another worrying about magic_quotes settings, an updated database schema for the project and the final about removing non-english characters in the title URLs.

0 comments voice your opinion now!
addendum base url magicquotes database schema utf8


IBM developerWorks:
Use an XML database in PHP and Java applications
April 03, 2008 @ 09:33:36

The IBM developerWorks site has posted a tutorial (you'll need to log in) showing how to use native XML databases to speed up development time for your applications.

Native XML databases have grown in popularity along with XML, because data is stored as native XML, rather than through tables in a traditional database. Using a native XML database means that a change to the schema requires minimal changes to your code and no change to the database. PHP and Java developers can benefit greatly from using native XML databases

IT talks about how to connect to the database (in this case DB2), grab the XML data via a query and how to insert information back in via a web-based form. There's also an example showing how to make a "search" on the data and how to change the schema of the database on the fly as well.

0 comments voice your opinion now!
xml database application tutorial db2 modify schema



Community Events





Don't see your event here?
Let us know!


tool symfony package podcast library language security community composer opinion voicesoftheelephpant install laravel interview release series update version introduction framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework