Remote Classes?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Remote Classes?

Post by Kadanis »

As I delve into OO, I was thinking about it in relation to the main app for the company I work for. Basically the app is spread over 5 servers. Each handling different stuff, but in some cases they all need to use the same classes. ErrorHandler, DirectoryManager e.t.c

Is it better to have a copy of these classes sat on the local file system for the scripts to use, or is it ok to use a URL in the require_once() function.

I know that PHP will let you use a URL, but I'm curious about it from a design point of view. Is it a good idea? or should I not touch it even with a 10 foot stick.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

While it's technically possible to use a remote page in require_once(), there is a performance advantage to having the files locally available. Plus you would need to either specially script in logic to handle the remote request unless PHP doesn't parse the file on the remote server.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I recommend version control.

Have one server run a subversion server and then check it out somewhere for that same server to use as well as on all the other servers. If any files are changed you'll have to commit it and update on all the other servers though you could probably use a cron job to run svn update every x minutes/hours.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

cron + SVN -- what a great idea ole.. I love it!

[open bag, insert trick]
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

Yet even a better method is to implement a post-commit hook using a python or other such script to publish the files to the server. This way if you make an update that needs to be published immediately, you don't have to wait for the scheduled cron job to run.

http://svnbook.red-bean.com/nightly/en/ ... eate.hooks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Either a post-commit hook, or better after a successful run of the test suite -- then I use rsync because it is so fast and easy.
(#10850)
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Post by Kadanis »

Wow, thanks again for all the replies. Some of it went a little over my head, so I think some serious reading is on the horizon.

I'll investigate the suggestions you made and have a go on the test system.

:)
Post Reply