News Feed
Jobs Feed
Sections




News Archive
feed this:

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

SitePoint PHP Blog:
Database Versioning with Ladder Migrations
April 22, 2014 @ 10:48:41

The SitePoint PHP blog has posted another tutorial looking at database versioning (see this postfocusing on Ladder migrations. Ladder is a simple PHP-based way to write migrations with rollbacks in a clear, easy to read format.

Version control systems are invaluable for tracking changes in your code, particularly when you're working in a team. However, most applications don't consist solely of application code. Managing changes to the database has always been a little more challenging, particularly when you're adding new features which require changes to the schema. [...] One solution is to move responsibility for creating and modifying the database schema into code, using migrations. That way, changes can be managed along with the rest of your application, and features we take for granted in version control - such as being able to compare versions and keep an audit trail - can be used for database changes.

He introduces the Ladder tool briefly, shows how to get it installed/configured and gets into writing a first simple migration. It creates a "users" table with two columns and comes with both "up" and "down" methods to make rollbacks easier. Ladder also provides functionality for database seeding, pre-populating the database tables with sample data either from hard-coded values or from a CVS file.

0 comments voice your opinion now!
database migration ladder versioning tutorial project

Link: http://www.sitepoint.com/database-versioning-ladder-migrations

SitePoint PHP Blog:
Database Versioning with DBV
April 21, 2014 @ 11:11:45

In this new post to the SitePoint PHP blog today Wern Ancheta introduces you to a tool that can help with database versioning, DBV. DBV is a tool developed by Victor Stanciu and made available on GitHub.

It's good practice to always use a version control system in any of your projects. Be it a side-project in which you are the only developer, or a team project where five or more people are working on it together. But the idea of putting your database into version control isn't really that widespread. Often times we take the database for granted. But like the source files in our project, the database is constantly changing too. That's why we also need a way to track the changes that we have made and easily share it to other members of our team. In this article we will take a look at DBV, a database version control system written in PHP for MySQL databases so you need to have PHP and MySQL installed before you can use it, along with a web server like Apache or Nginx.

He steps you through the installation (via an installer and configuration through the "config.php" setup file. The system keeps track of lots of different changes including new tables, updated field descriptions, additional views, stored procedures and functions. He includes some screenshots of the UI and goes through the workflow of adding new tasks and syncing with a remote database server.

0 comments voice your opinion now!
database version tutorial dbv github

Link: http://www.sitepoint.com/database-versioning-dbv/

PHPBuilder.com:
Using PHP Configuration Patterns Properly
April 16, 2014 @ 11:52:11

On PHPBuilder.com today they have a new post showing different configuration patterns for getting localized settings into your applications. They show the use of INI files, PHP scripts, text files, XML data and a database call.

PHP is a cross platform language. It is a server based application so we must think about the configuration settings of the PHP software. There are various ways of creating configurable PHP applications. The configuration flexibility comes as a built in feature in PHP. But we must understand the requirement clearly before making an application configurable. This article explores different PHP configuration patterns and their implementation.

For each of the options mentioned, there's a brief description of what the method is, some of the common uses and a code example showing a basic implementation. The database pattern is the only one without a code example as the database interface varies widely from application to application.

0 comments voice your opinion now!
configuration pattern ini script text xml database

Link: http://www.phpbuilder.com/articles/application-architecture/using-php-configuration-patterns-properly.html

Sameer Borate:
Calculating descriptive statistics in MySQL
April 08, 2014 @ 10:46:22

Sameer Borate has shared some examples of how to generate some meaningful statistics about the contents of your database in a new post to his site today.

Descriptive statistics can be quite useful for simple analysis of records in a database. For example, to calculate average numbers of sales or products for a particular duration, or the Variance of sales for a month etc. We can easily calculate standard descriptive statistic measures in MySQL such as MEAN, SUM, STANDARD DEVIATION, VARIANCE, MIN and MAX using built-in functions.

He includes both the SQL and a bit of PHP code showing how to get these statistics (based on a simple data set of student scores). The PHP is required to more correctly evaluate the median and mode values as it's easier to evaluate those in PHP.

0 comments voice your opinion now!
mysql database descriptive statistics mean sum mode median

Link: http://www.codediesel.com/data/calculating-descriptive-statistics-in-mysql

SitePoint PHP Blog:
Building a Simple Blog App with MongoDB and PHP
March 14, 2014 @ 09:19:36

On PHPMaster.com there's a recent tutorial posted showing you the creation of a simple blog application with MongoDB + PHP. It's a basic overview, so it's mostly about creates and reads, but it does help get things working.

If you want to create a blog using MongoDB and PHP, this article will teach you. [...] The reason I chose to build a blog application is because it is a basic CRUD application and it is very suitable for easing into PHP and MongoDB web development. We will build a plain user interface using Bootstrap with simple textboxes and buttons. A MongoDB database will store all the content.

He starts off by introducing MongoDB and some of the basic concepts around databases, collections and documents as they relate to it. He then moves into the installation process, getting and configuring a simple MongoDB instance running on localhost. He helps you get the MongoDB PECL driver installed for PHP and includes a bit of code to test the connection. Finally, he gets into the blog example itself and includes the full code to get it up and running.

0 comments voice your opinion now!
tutorial blog application sample introduction mongodb database

Link: http://www.sitepoint.com/building-simple-blog-app-mongodb-php/

Ross Tuck:
Persisting Value Objects in Doctrine
March 03, 2014 @ 10:11:29

Ross Tuck has submitted a new article he's posted about persisting value objects in the popular PHP database storage and object mapping library, Doctrine. Value objects are immutable objects that " follow value semantics rather than reference semantics".

I've been using more and more Value Objects in my applications over the last year, primarily with Doctrine ORM. Value Objects are an extremely powerful technique and I've been impressed with how much they can clean up a codebase. One of the main questions I've had when starting with Value Objects is how to persist them with Doctrine. This post attempts to create a reference for all the different persistence techniques I've seen so far.

You'll need to be familiar with Value Objects and Doctrine before starting (it's not an "intro to Doctrine" article). His example sets up an "IPRange" and an "IPAddress" that are stored in a "Server" instance. He talks about mapping the value object to the database and the getter/setter to do the work. He also touches on DBAL types, working with multiple columns in the entity and the "promised land" of embeddables. He finishes off the post looking at collections of entities and some of the other options to what he's shown (including serialization).

0 comments voice your opinion now!
doctrine valueobject value object database entity dbal embeddables

Link: http://rosstuck.com/persisting-value-objects-in-doctrine/

SitePoint PHP Blog:
Data Fixtures in Symfony2
February 27, 2014 @ 12:50:44

The SitePoint PHP blog has posted a tutorial from Taylor Ren looking at the use of fixtures in Symfony2. Fixtures allow you to create a set of test (or just initial) data to populate the database in an automated way.

Back when I first started to learn Symfony (1.x) with its Jobeet project, I thought the ability to load a bunch of test data into the database very useful. In this article, we will revisit this feature, which has been completely re-modeled and thus has a lot to teach us.

He uses two third-party libraries to give the Symfony application a bit more "power" - the DoctrineFixturesBundle and PHPUnit. The second is used for testing the results of the fixtures, not the actual loading process. He walks you through the creation of your first fixture file for a book-based example. The fixture uses the Doctrine functionality to create "place" data. He includes the command to run the fixture (via the Symfony app/console command) and what the result should look like. He comes back around and shows the same process with other general book data, also talking about primary keys and references.

0 comments voice your opinion now!
data fixture database symfony2 application tutorial example

Link: http://www.sitepoint.com/data-fixtures-symfony2/

MaltBlue.com:
3 Simple Ideas for Improving Zend Framework Performance
January 23, 2014 @ 10:27:55

Matthew Setter has shared three tips to improve the performance of your Zend Framework-based application on his MaltBlue site today:

Today, I want to take you out left field a bit. I want to take you a little away from the everyday, potentially clichéd, advice you likely read when it comes to improving Zend Framework 2 application performance. There's likely nothing wrong with it; but I'd say you've already read it many times. Instead, I'll show you 3 strategies you may not have thought of - specifically focused around the database. That way, when combined with the standard advice, you'll be better able to improve performance of your Zend Framework application.

As mentioned, his three tips involve working with database connections and resources:

  • Improve your database skills
  • Learn key database features
  • Move logic to the database layer

This final tip advocates the use of things like stored procedures and triggers to handle some of the logic load of the system. This also reduces some of the network overhead as not as much information is having to be pulled "over the wire" as before.

0 comments voice your opinion now!
improve performance zendframework2 application database

Link: http://www.maltblue.com/zend-framework/3-simple-ideas-for-zend-framework-performance

PHPBuilder.com:
Implementing Automatic Database Backup and Optimization in PHP
November 27, 2013 @ 10:52:31

On PHPBuilder.com today they have a new article posted sharing a few different methods you can use to do backups of your (MySQL) database and a few handy tricks/tools you can use to optimize it as well.

Every computer system has a backup. Nevertheless, the number of problems caused by a lack of a recent backup is huge. One of the reasons for that may be the fact that the backup process is not entirely automated. So, let's see how to automate the database backup process in PHP.

There's three recommendations for the (simple) database backup that can produce a file of the current database contents - mysqldump, mysqlhostcopy and a "SELECT INTO OUTFILE" statement. On the optimization size they suggest mysqlcheck, an OPTIMIZE query to help find trouble spots. There's a script included at the end showing how these methods can be combined into a simple PHP script, something that can easily be dropped into a cron job to perform every so often.

0 comments voice your opinion now!
automatic database backup optimization

Link: http://www.phpbuilder.com/articles/databases/mysql/implementing-automatic-database-backup-and-optimization-in-php.html

Phil Sturgeon:
Build API's That You Wont Hate Part 1 - Useful Database Seeding
November 11, 2013 @ 09:19:33

Phil Sturgeon has posted the first part of a series he calls "Build API's That You Won't Hate", a follow up to one of his previous posts about building good APIs in your application.

A little while back I produced an article called Building a Decent API which was mostly a tongue-in-cheek list of things that I'd come across in other APIs that pissed me off, or that I had done myself and used my super-power of hindsight combined with sarcasm to make a set of rules for you to live by when building APIs. The combination of cheek and naughty words made that "eat your greens" article go down a lot more smoothly, but it certainly lacked a little substance but I always wanted to turn that into a much more in depth of blog posts.

In this first part of the series he covers one main topic - generating "good" data for you to use in your development environment. As he points out, using production data in development databases dangerous for several reasons. He suggests the Faker library to do what's called "database seeding" and generating fake, but accurately formatted, data to use for testing. He includes some sample code showing how to use the PHP tool to generate as set of seed user data. He also shows how to create a DatabaseSeeder class for Laravel and integrate it with the tool.

0 comments voice your opinion now!
api development database seeding faker laravel

Link: http://philsturgeon.co.uk/blog/2013/11/build-apis-part-1-useful-database-seeding


Community Events











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


hhvm performance facebook database release podcast package component language symfony2 overview unittest introduction hack framework application security install composer opinion

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