Forums / Extensions / SVN Post Commit Hook to import/update content objects - what's the best practice on where to create a /bin/php script

SVN Post Commit Hook to import/update content objects - what's the best practice on where to create a /bin/php script

Author Message

Conrad Decker

Thursday 07 October 2010 12:31:31 am

Hi All,

I'm creating a PHP script that will handle importing content objects into the content structure using the eZPublish api and a 'simple' PHP script, similar to what is done in this tutorial. I'm curious what the best practices are for where to place this file in the eZPublish directory structure. According to the tutorial, it looks like it should be placed in the /bin/php directory, my only concern would be is this going to be an issue if eZ is ever upgraded? Is it possible to put this script in an extension so that it could be easily moved around with the extension? I guess it could essentially be placed anywhere in the directory structure assuming it has access to the required autoload file?

The concept for the script is actually pretty straight forward, but I'm open to recommendations if anyone has any thoughts as to a better way to achieve this. The plan is to store a bunch of binary files on a network drive. Periodically, a scheduled process will run through the directory and add any unversioned files to SVN, delete any versioned files that no longer exist, and commit all changes to an SVN repository. On the repository side there will be a post-commit hook that will send an update to the script that I'm creating with information regarding which files have been added, modified, and deleted. This script would then grab the new/modified files and import/update them in eZ, and delete any files that have been removed from the repository.

The end goal is to essentially keep a local drive, and a publicly web accessible file repository in sync. Webdav was my original thought process which works great, but the biggest issue I've run into is that the folders/files that we're trying to sync have different naming conventions then the URL alias naming convention that Webdav uses for displaying folders/files to the webdav client so keeping the two directories in sync using an automated process has become a pain in the butt.

I'm absolutely open to any suggestions should anyone have something they think may be a better solution, but in the meantime I'm going to keep trucking away...hopefully it'll help someone else with a similar problem down the road.

Any/all help is certainly appreciated. Thanks!