SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Location
    Canada, Alberta
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checking versions with php

    this is purely an academic question.

    question: What is the best way to handle version checking in php.

    example: Let's say I have a CMS like script and so does other users, and I have the version number defined somewhere in the script, and on a certain page, it should compare the current version number with the version hosted on my server or a SVN/GIT repo.

    I'm not looking for an entire script, I just need someone to point me in the right direction to find the "best"/most recommended practice.

    like is it possible to get data off a specific URL on a different server? or is it better to do this via ajax and just print the version number in a hidden field?

    Thanks

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What kind of half-baked language would PHP be if it couldn't make network connections? Here's an example:

    PHP Code:
    $version file_get_contents("http://www.example.com/script-that-returns-current-version-number.php");
    if (
    $version != CURRENT_VERSION)
        echo 
    "You need to upgrade. You're running version " CURRENT_VERSION " but the current version of this script is $version."
    That's all there is to it.

  3. #3
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Personally i like using mod_rewrite to spoof a URL to the version tracker so the url would be something like "example.com/version.json" but really it would link to the file like Dan Grossman showed in his example above.

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2010
    Location
    Canada, Alberta
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Dan Grossman Oh cool, I never would have thought it was that simple. Here I was thinking that there was some magic library or class or whatever that I'll have to download... haha thanks for the info.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •