techcone Posted August 17, 2010 Share Posted August 17, 2010 I am a freelancer, I design my own custom scripts and mods. The major problem with my script is they run alright on my local server (XAMPP) but when I deploy them on my clients server (more then 20-30), they sometime break because I dont know what is exactly required by my script. Then I do poor man's debugging to track the error. Can please someone tell how can I find what are basic requirements of my script ? Should i use function_exists() method to find if everything is present on production server ? Any more ideas folks ? Quote Link to comment https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/ Share on other sites More sharing options...
JasonLewis Posted August 17, 2010 Share Posted August 17, 2010 Most (I say most) servers should be running PHP5 at least. When coding an application, you should take note of some of the more newer functions you use and the available versions they are on. If you are making an application that you want to run on many different environments and need to make use of a function available on a PHP version that is fairly new, then you should make use of function_exists() so that you can re-create that function. Quote Link to comment https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/#findComment-1100176 Share on other sites More sharing options...
techcone Posted August 17, 2010 Author Share Posted August 17, 2010 So the good method is to create a simple php file that tests the presence of all functions required by my script correct ? And I should ask them to upload that php file on their server and test if it passes all the tests, correct ? Quote Link to comment https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/#findComment-1100178 Share on other sites More sharing options...
JasonLewis Posted August 17, 2010 Share Posted August 17, 2010 Yeah that's how I do it with some applications, have an environment test file. Checks the PHP version, required extensions that may be used etc. Quote Link to comment https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/#findComment-1100179 Share on other sites More sharing options...
Alex Posted August 17, 2010 Share Posted August 17, 2010 What you're dealing with is portability. There are many techniques that you can use to ensure that you code is portable and works on all systems that you'll be deploying it on. Some things are very simple rules of thumb, and others are more complicated. One example of a simple rule you should always follow is never use short tags (<? ?>). Using the full tags (<?php ?>) ensures that you code will still work on PHP installs that have short tags disabled. As new versions are released they offer new optimizations, features, changes etc.. You can use phpversion to check the version of PHP, or a more specific extension, that is being run. From this you can decide what your code will do; For example, if you decide that you want to make your code PHP 4 compatible and you're using OOP you'll have to write an alternative solution that doesn't use the OOP features that weren't introduced until PHP 5 (e.g. the public/private/protected visibility keywords). While you're writing your code you should make sure that the functions you're using all available in the versions of PHP that you hope to support; the PHP manual does a great job of telling you this. If they're not you need to make sure to provide an alternative solution that will be supported. Quote Link to comment https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/#findComment-1100180 Share on other sites More sharing options...
techcone Posted August 17, 2010 Author Share Posted August 17, 2010 My most methods are just php 5 base methods, so making an alternative solution to the methods is not required at all. Thanks for the input guys You are doing a great job. Quote Link to comment https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/#findComment-1100181 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.