… Well not quite, but I’m sure most ASP.Net programmers would refer to it in this fasion. If you’re coming form another web application framework, then this is well worth looking into.
This project came into focus for us when we had a client with a preexisting web application in need of a drastic rewrite. The catch was the time. We literally had 3 days!!
Well, considering (as I’ve mentioned before) I’m not the greatest PHP programmer out there. In fact, before this, my most extensive work with PHP was a discussion board and FAQ comment system tied to a CRM. But, as they say in England, you’ve got to keep a stiff upper lip at these types of situations.
I would highly recommend downloading Uniform Server if you’re on a Windows machine. It’s, by far, the easiest method of creating a complete Apache/PHP/MySQL platform painlessly for Windows systems. Also of note is the nice admin panel, which, though rather sparse, gets the job done and is easy to use.
The first step is pretty basic. Get your server running and then navigate to W: in a command prompt (This is where the server will mount when running).
Note : The commands to type are in bold white.
c:>w:
w:>cd usrlocalphp
w:usrlocalphp>
Now we’re going to use Pear to access the Symfony repository.
w:usrlocalphp>pear channel-discover pear.symfony-project.com
If your system for some reason cannot identify PHP (some users noted this problem), then use the full path of PHP.
w:usrlocalphp>w:usrlocalphppear channel-discover pear.symfony-project.com
Once that’s done, we’re going to install it
W:usrlocalphp>php -r "readfile('http://pear.php.net/go-pear');" > go-pear
Again, if it doesn’t recognize this, use the full path as the above example.
W:usrlocalphp>w:usrlocalphpphp -r "readfile('http://pear.php.net/go-pear');" > go-pear
Now you will be prompted with a few installation options.
Note: All these are without quotes…
For : “If you wish to abort, press Control-C now, or press Enter to continue: ”
Press : “Enter”
For : “HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:”
Press : “Enter”
For : “1-8, ‘all’ or Enter to continue:” (This is regarding the executable directory)
Press : “Enter”
For : “Would you like to install these as well? [Y/n] :”
Type : “y”
For : “Would you like to alter php.ini ? [Y/n] :”
Type : “y”
Now as of this post, the version you have just installed is the 1.1.x branch. It’s the stable branch and works well.
My suggestion afterwards is to visit the cookbook so you can quickly get in touch with the basics. Also take a peek at the video tutorial on the Admin Generator. It isn’t very difficult, but be thorough when you go through this. Missed steps or oversights can cause some issues down the road, so double-check your work.
Aside from the command line fiddling and a few manual edits, Symfony can get a great deal accomplished in a very short period of time.
Using the Admin Generator, here is my experimental (and very minimal) MySQL database generated by the tool :
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
#-----------------------------------------------------------------------------
#-- articles
#-----------------------------------------------------------------------------
DROP TABLE IF EXISTS `articles`;
CREATE TABLE `articles`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`description` VARCHAR(255),
`content` TEXT,
`abstract` TEXT,
`author_id` INTEGER NOT NULL,
`category_id` INTEGER default NOT NULL,
`is_published` INTEGER,
`date_pub` DATETIME,
`date_created` DATETIME,
PRIMARY KEY (`id`),
INDEX `articles_FI_1` (`author_id`),
CONSTRAINT `articles_FK_1`
FOREIGN KEY (`author_id`)
REFERENCES `users` (`id`),
INDEX `articles_FI_2` (`category_id`),
CONSTRAINT `articles_FK_2`
FOREIGN KEY (`category_id`)
REFERENCES `categories` (`id`)
)Type=InnoDB;
#-----------------------------------------------------------------------------
#-- users
#-----------------------------------------------------------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`username` VARCHAR(50) NOT NULL,
`password` VARCHAR(50) NOT NULL,
`display_name` VARCHAR(255),
`first_name` VARCHAR(255),
`last_name` VARCHAR(255),
`email` VARCHAR(100) NOT NULL,
`avatar` VARCHAR(255),
`bio` TEXT,
PRIMARY KEY (`id`)
)Type=InnoDB;
#-----------------------------------------------------------------------------
#-- categories
#-----------------------------------------------------------------------------
DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`abstract` TEXT,
`photo` VARCHAR(255),
`is_private` INTEGER,
PRIMARY KEY (`id`)
)Type=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
Not the best example out there, but you can see what I was aiming for.
The great thing about this is that you can very quickly create the basic functionaly of any web application from CMS to CRM to Blog with plenty of flexibility and room to fix errors.
Highly recommended if this is the first time you’re dealing with a web framework. Also, a good way to improve your PHP.
This example was setup on a Vista PC.