Tue, 18 Aug 09
Posted in PHP, Web Applications, Drupal at 8:30 pm by moore
I have spent some time researching Content Delivery Networks (CDNs) and how they can integrate with Drupal. Note that I have not yet implemented a CDN solution, so my experiences and opinion may change…. I will try to do a second post or update when we’ve actually rolled something out live.
Here are some criteria I’d use in selecting a drupal module for CDN management:
- Do you need a CDN? This is the key question, as a CDN can speed up your site, but introduces a layer of managment and expense that might not be worth the hassle.
- Do you mind patching drupal core? This might be a maintenance issue going forward.
- Do you want to have just images on your CDN, or javascript and CSS as well? What about video?
- How contained within the drupal interface do you need your interactions with a CDN to be? Are you comfortable using a third party tool sometimes?
- Do you have an existing CDN to work with, or are you selecting a CDN from scratch? Obviously, you have more flexibility in the second case.
- Do you mind coding? Some of these modules seem like they are 75% of the solution, but you might need to write some code to finish things up.
There are a number of modules that attempt to integrate a CDN into Drupal, or might help doing so. All of these had a release for Drupal6.
- CDN: this seems like a great fit. Active development, good sized issue queue, support for multiple CDNs. It also patches core. Here’s a list of CDNs used with this module.
- media_mover: this module seems like it might be useful if you were needing to move image and or video files to a CDN. That might require some coding, although I remember there being some S3 and FTP support.
- creeper: this module is all about Amazon API integration, including CloudFront. Plus, what a great name!
- parallel: fairly new module that changes the source hostnames of images, css files and javascript html tags. Therefore, they can be served off a CDN, or another web server, etc.
- storage_api: this is a general storage service with a CDN focus, but doesn’t appear to be well documented or supported as of this time.
- cloudfront: adds Amazon CloudFront support to the imagecache module
These all seem to be useful in their own ways. The current project I’m working on is already invested in the Amazon infrastructure, mainly because of Project Mercury, so cloudfront is our current choice.
Did I miss any key modules?
Technorati Tags: drupal cms, cdns rock
Permalink
Fri, 07 Aug 09
Posted in PHP, MySQL, Useful Tools at 9:05 am by moore
phpMyAdmin is a pretty cool piece of software, and a very useful tool. If you haven’t used it before, it’s a full featured web-based interface to MySQL databases. You can use it to add data, update data, delete data, export data, and basically any other management of the database you might need.
I ran into an issue the other day. I was trying to allow phpMyAdmin to access a database on a remote host. The user that phpMyAdmin was connecting as didn’t have the “show databases” privilege (I imagine this is common in shared hosting environments, which is what this was). This, apparently, is what phpMyAdmin uses to populate the drop-down of databases on the left-hand side after you login. Since it didn’t display that drop-down, there is no way of selecting the database to which this user did have access.
I searched for a while, but couldn’t find anyone else with this problem. So I thought I would post the solution I found.
The solution is to hard code authentication data for the remote server in my config.inc.php file. Then, you append the server and the database that you want to connect to the phpMyAdmin url.
In the config.inc.php file:
$cfg['Servers'][$i]['host'] = 'xxx.xxx.xx.xx';
$cfg['Servers'][$i]['user'] = 'user';
$cfg['Servers'][$i]['password'] = 'pass';
In the url that normal users use to access the database:
http://phpMyAdmin.example.com/phpMyAdmin/index.php?db=databasename&server=xxx.xxx.xxx.xxx
The left hand side still isn’t populated with any databases. But, this allows you to go directly to the database to which you do have access, and perform whatever tasks you want (and have permissions for). I tried adding the “db” parameter to the config.inc.php file, but that didn’t seem to work. I didn’t try using any other form of authentication than hardcoded, as I wanted to make this as simple as possible for the phpMyAdmin users.
I was running an older version of phpMyAdmin (2.11.9.5); I didn’t test this on newer versions. If you do, please post a comment and let me know if this still works.
Technorati Tags: phpmyadmin, mysql privileges, remote database access
Permalink
Tue, 02 Jun 09
Posted in PHP, Web Applications, Drupal at 9:32 am by moore
AKA, my time with the blue droplet. I recently built a website for a client. I initially recommended wordpress, as I often do but the client suggested the website would grow into an application. You can certainly do webapps with wordpress, but it seemed worthwhile to look at alternatives. Drupal 6 seemed to fit the bill:
- flexible
- lots of documentation (always important in any evaluation)
- great community
- tons of additional functionality (called plugins)
- customizable UI
- multiple languages supported
So, the site is launching soon and I thought I’d jot down my thoughts. Keep in mind that I’m very much a drupal newbie.
The good:
- I was astonished at the plethora of modules. In fact, just about everything we needed to do functionally was done; it was a matter of getting the right modules installed and configured. I don’t think I wrote a single line of code, though I did do plenty of code reading.
- The look and feel were very customizable. I ended up using a large number of blocks (isolated chunks of content that you can control and place). The ‘clean’ theme was pretty easy to customize via CSS. The Web Developer add on for Firefox was invaluable for this process–just hitting ‘control-shift-C’ and mousing over a component let me know what selector to use.
- WYSIWYG support was pretty good, including image uploading (as a separate module), control of which of the TinyMCE buttons to display, and a dropdown to surround text with custom css class names. I ended up using the HTML Purifier to scrub input from admin users.
- The webform module allows non technical users to create complicated forms quite easily. I didn’t really push this module, but it appears to have support for multi page wizards and other complex stuff. But just using it for validation of required fields saved a lot of effort.
- Drupal6 has a robust upgrade mechanism. At least, it sure seems like it–I have upgraded modules and the core functionality a few times and haven’t had any issues.
My issues:
- We started off on a medium strength server, and were not caching much, and performance was a big issue. There are a number of resources out there, and some research is worth your while. Drupal is a big, complicated system, and like all big complicated systems, tuning is a continual process. Luckily, there’s a fair bit of built in caching that can be enabled with a checkbox.
- Deploying from one server to another is an issue. I talked to a friend who does a lot of Drupal development and he mentioned it was a real thorn in the side of drupal. There’s just not that much available supporting the ability to move code from staging to production and content the other way. To be fair, this is an issue for most CMSes, and there are some project (deploy is one of them) attacking this issue. I don’t know of any open source CMSes that solve this problem entirely.
- The SEO components seemed pretty good, but I was surprised that they weren’t bundled with the base Drupal installation. You have to install a module to enable meta tags. And another one for page titles. Page titles! (I looked at but was quickly overwhelmed by installation profiles, which might obviate some of the module installation. There didn’t seem to be much support for Drupal 6 profiles.)
- The complexity of Drupal, which allows it to do so much, means that there’s a lot to learn. It can be a bit overwhelming at times.
The long and short of it:
If you’re looking to build a web application (not just a site), have some php expertise and some time to get up to speed, and need a lot of functionality, Drupal is worth looking at.
Technorati Tags: cms, php cms, drupal, blue droplets keep falling on my head
Permalink
Thu, 25 Sep 08
Posted in PHP, Web Applications at 9:39 pm by moore
Are you using Wordpress as a CMS? Are you using a backrev version of wordpress? Do you have an existing design that relies on div styling in the content area, but want to allow use of the WYSIWYG editor for most text?
It’s your lucky day, if you’re using WP 2.3. Edit the tiny_mce_config.php as outlined at this article and rejoice.
Technorati Tags: wordpress, cms, tinymce
Permalink
Fri, 20 Jun 08
Posted in Java, HTTP, PHP at 5:30 pm by moore
I am currently working on a project that uses a PHP CMS for the bulk of the site. However, it pulls some content from a page generated by JSTL on a tomcat. I was using the fmt tag to do some pretty printing of numbers, and it looked fine when I viewed the content as served by tomcat. However, none of the formatting was carrying through when the PHP page included the jsp. Why? It appears that the fmt tag needs a locale. I confirmed that with wget.
Now, how to set the header with the PHP include. The include man page was no help, and mod_rewrite won’t let you modify headers, as far as I can tell. Once the request arrived to tomcat, that was too late.
Some digging around in the PHP documentation on fopen turned up this gem:
Custom headers may be sent with an HTTP request prior to version 5 by taking advantage of a side-effect in the handling of the user_agent INI setting. Set user_agent to any valid string (such as the default PHP/version setting) followed by a carriage-return/line-feed pair and any additional headers. This method works in PHP 4 and all later versions.
Click through for a code example. The aforementioned documentation talks about custom headers, but it worked for sending the Accept-Language header that the fmt tags needed.
Permalink
Thu, 05 Jul 07
Posted in Programming, PHP at 12:39 pm by moore
I just wanted to say: if you are building an application in PHP and you need to edit or search data from a relational database, HTML_QuickForm, DB_DataObject, and, occasionally, DB_DataObject_FormBuilder, can be very useful for prototyping and, depending on your client’s needs, building. The tools are well worth a look if you’re planning to write any custom PHP database manipulation code.
Permalink
Tue, 15 May 07
Posted in Java, Dynamic Languages, PHP at 11:10 pm by moore
Have you ever had a project written primarily in PHP, but there were some java systems that you wanted to connect to? Perhaps there was a third party library or a java API that you really want (or are required) to use, but PHP had been chosen for other reasons.
The php java bridge is your solution. The documentation is good, and the performance is pretty darn good (if you’re looking for benchmarks, search for ‘How fast is it?’). You can use the bridge over sockets, a xml based protocol via servlets, or over a mono application. The mailing list is active, and it looks like the primary developer actually answers questions on said list (as of May 2007).
I’ve always been a bit hesitant regarding cross language programming: “Great, now I get to debug in two languages that communicate via sockets! Yahoo!”. But for a certain set of circumstances, using this bridge can be the right answer.
Technorati Tags: php, java, cross-language programming, php java bridge
Permalink
Sun, 11 Mar 07
Posted in PHP, Web Applications at 1:24 pm by moore
A couple of weeks ago, I mentioned I’d be reviewing MODx in the near future. I recently used it and was quite impressed by this project. It is a web CMS written in PHP with mysql as the datastore. I say ‘web CMS’ because MODx is designed to manage web content, as opposed to a more enterprisey CMS like StoryServer, which can manage all different types of content with complex workflows. You could use MODx to manage, say, printed brochures, but that would take some finagling. Web content is the sweet spot of this framework. Currently at version 0.9.5, it is fairly mature and ready for use.
I wanted to review MODx because I believe it deserves more attention, and as an example of how I’d evaluate an open source project, on the back end, rather than on the front end, of a project.
The good:
- full featured
- I was able to find everything I needed in MODx, or in the extensions repository. This included a thumbnail generator, email forms, integrated rich text editor, SEO friendly links, database updating forms, and a content redistributor (that syndicated content internally within the site).
-
admin interface
-
I think the administrative interface is excellent for non technical users. It’s responsive, and intuitive.
-
user access/authentication system
-
There’s a very well thought out access system. You can assign users to roles, which lets them access certain
functions in the admin interface, and groups, which define groups of documents that a user may modify. Here is more documentation on this feature.
-
defined development architecture
-
When you start working with MODx and you want to do something more than a cookie cutter website, you start hearing jargon, like snippets, plugins, chunks and template variables. All of these are MODx specific concepts, and it takes a while to wrap your head around them. But when you do, you appreciate the thoughtfulness of the architecture. In particular, you rarely have to modify existing source–there are hooks and easy ways to tie in custom code. (Most of these hooks are for the user side–to modify the admin interface, I had to hack some existing PHP.)
-
community
-
The MODx forums are the heart of the community. There are quite a few active members. I found the community to be very responsive and friendly to any questions I had, no matter how dumb.
-
a growing set of extensions
-
The MODx repository has a number of useful extensions. I especially liked that each entry in the repository is labeled with the version of MODx it supports.
-
active development
-
The project has gone from start up to 0.9.5 in less than two years.
-
open source
-
The license is GPL version 2.
-
caching
-
You can turn on a simple form of caching, which will serialize a generated page to disk. Unfortunately, there’s no way to expire that cache. You can delete it, on a site wide or page by page basis, but you can’t say ‘expire the cached version of this page in one month’. Still, for many pages, this is an appropriate form of caching and can noticeably speed up the site.
The bad:
- documentation
-
There is a ton of documentation for MODx, even a wiki. But I always felt like I was missing something–either it was hard to find what you wanted, or when you did, it wasn’t enough. An example is the API documentation. Here’s a sample function call that you’d make on the $modx object. No explanation of the returned data structure is available, and no actual example of how to call this function. I became very friendly with var_export($var,TRUE); and print statements to navigate these returned structures.
-
dependency on the database
-
MODx is very tightly bound to mysql. No problem there–mysql is a great database. But I mean, it’s really tied to mysql. By default, all code you write (see ‘defined development architecture’ above) is stored in the database. That’s not the place for code! Luckily, you can avoid that by using an include: include($modx->config['filemanager_path'].'/assets/libs/thumbs/thumbplugin.php');
This way, the code is on the file system, and can be versioned, etc. Also, since MODx depends on the database for so much functionality, make doubly sure you backup the database.
-
error messages in development
-
PHP syntax errors can be hard to track down. I ended up using a lot of command line debugging: php -l -f foo.php and looking in error log to see messages.
-
5000 document limit
-
This is a big one. Because of the caching mechanism, you can’t have more than 5000 documents in a MODx website. However, this is acknowledged as a lack, and the team is working on it.
-
no search in specific forum
-
The forums are great, and are divided up into various sections. However, there was no way (that I could find), to search within a particular forum, or even within just the forums. This meant that when you were searching, you ended up with a lot of extraneous results.
Sure, MODx isn’t right for every site. But if you have a PHP savvy developer, a non technical userbase, requirements more complex than brochureware, and want to get a site up and running quickly, MODx is worth a look. As I’ve said before, use the right tool for the job.
Much thanks to the developers of MODx for putting together a great generic web CMS development platform!
Update 11/2009: HostColor offers MODx hosting for a reasonable price. If you’re looking, check ‘em out (click the CMS Hosting link). Disclaimer: I make a bit of money if you visit them and/or sign up.
Technorati Tags: modx, php, web cms
Permalink
Tue, 09 Jan 07
Posted in PHP at 4:59 pm by moore
I’m doing some work for a client using the MODx CMS. I will be writing more about that cool framework later, but I wanted to let the world know that xo.com hosting does not allow file upload via php scripts.
It doesn’t matter what your php.ini file says, the hosting environment doesn’t allow it. I was so astonished by an email telling me this that I called their customer service. Very politely, the fellow on the other end of the line repeated the prohibition. I asked “So, if I need file uploads, the only way to get them is to leave XO.” He was pretty uncomfortable, but said that was the case.
I guess westhost.com has spoiled me. I simply can’t believe that a modern hosting service wouldn’t allow that kind of fundamental functionality.
Am I off base here? Do most hosting providers prohibit this functionality? Did I just not talk to the correct folks at XO?
Technorati Tags: php, file upload, xo.com
Permalink
Sat, 11 Nov 06
Posted in Programming, PHP at 10:38 am by moore
I recently wrote a PHP file upload application. Yawn, right? There’s a manual entry on this task, which tells you just how often folks need to do it.
Well, I threw in a few new tricks–they were new to me at least. Basically, instead of posting to a page in the typical way, I post to a 1px by 1px invisible iframe, which then generates some javacript:
<form action="/upload.php" enctype="multipart/form-data"
method="post" target="target_upload">
<iframe id="target_upload" name="target_upload"
style="border: 0pt none ; width: 1px; height: 1px">
———–
<script type="text/javascript">
if (parent && parent.uploadFinished) {
parent.uploadFinished(<?php echo $result;?>);
} </script>
The next question is how to communicate from the iframe, which is handling the processing, to the parent window, which is where the user interface is. The upload process parses the file and puts it in a database. If there are any errors, the parsing code ouptuts “0″, otherwise, it returns “1″. This value is passed to a javascript function which is written to the iframe. It looks something like the above, where the uploadFinished function basicly shows divs containing an appropriate message.
How is this superior from a regular page post? Not by very much. It’s not truly asynchronous–you still see the browser wheel spin. The only browser actions you can take while an upload is proceeding are those that open in a new window. That’s not much, but it’s more than a normal post allows you to do. In addition, this is relatively easy to do and you don’t have to deal with creating a new ’successful upload page’.
Technorati Tags: PHP, file upload
Permalink