SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Local Machine Setup for PHP

    Hello

    I am a Java developer who is thinking about learning PHP since finding affordable reliable Java hosting is very difficult.

    I have been researching what it takes to setup a developer’s local machine and here is what I have found. I was hoping someone would be willing to validate the steps I am taking to avoid potential issues.

    First – download PHP

    http://www.php.net/downloads.php

    Second – setup server

    What I have read is that I can use IIS or Apache. I have a Windows machine running XP so I assume IIS would be the easiest for me. Is this true? One thing I like about Java is that I have Eclipse setup as a Dynamic Web Project with Tomcat so when I hit save, Eclipse compiles and publishes my code for me. I realize PHP is not compiled, but is there a server that works well with Eclipse for PHP so I can setup my local environment in a similar manner?

    I also saw a Zend server… is this a good option?

    http://www.zend.com/en/community/pdt

    Third – Setup PDT in Eclipse of PHP

    http://www.php.net/downloads.php

    Four – Install MySQL

    http://dev.mysql.com/downloads/

    After I complete these steps, should my environment be setup and ready for PHP development?

    Any feedback would be appreciated.

  2. #2
    messing with my mind fristi's Avatar
    Join Date
    Feb 2009
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    two easy shortcuts if you don't want to waste time on your environment and only want to program:

    http://www.wampserver.com/en/
    http://www.usbwebserver.com/

    these are two install files which will configure and install all needed components
    To PHP or to Perl, that is the question!
    (Bucket - simpletest) User

  3. #3
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,028
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    An easier way would be to install the WAMP server. Any windows PC built in the last 4 or so years should run it fine
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,407
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I use XAMPP http://www.apachefriends.org/en/xampp.html and do not have any problems.

    Some people say "You should set it up yourself so you know how a server works." My attitude is I do not care how it works as long as it works

    Note: You do not need to use IIS and I think a Linux setup is more useful.

    You can add php to Eclipse - http://www.eclipse.org/pdt/ I belive you can use php with Netbeans as well http://www.netbeans.org/
    Last edited by Rubble; Jul 9, 2009 at 12:17. Reason: Note about server

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    It all depends on what you want to do with it!
    If you just want a testbox then as Rubble and the others have said, chuck a WAMP server setup on it. If you want to learn how your server works and how to configure server side of things then set up each installation.

    Personally my setup on all machines is:

    Apache Server
    PHP 5.x
    MySQL

    That way I can play with the Apache configuration and more importantly htaccess/mod_rewrite.

    It is personal choice and up to you!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    ¬.¬ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Well since you said you are using Windows XP, I cannot recommend IIS for that version. Now if you were using Windows Vista or above, I would highly recommend IIS 7.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for all the feedback.

    For servers, I really do not want to know any more than I have to… I agree with the statement by Rublle… I don’t care how it works as long as it works.

    I also want to use the Eclipse plugin for PHP. I currently have Eclipse and MySQL installed on my local machine which I use for my Java development. I was just going to download the PHP plugin.

    With this said, which server would you guys recommend for me?

    It sounds like XAMPP.

    Maybe I am not understanding the PHP setup completely, but I would like for Eclipse to build the PHP web project and everything. Does XAMPP work in Eclipse like Tomcat does for Java?

  8. #8
    SitePoint Addict Mastodont's Avatar
    Join Date
    Mar 2007
    Location
    Czech Republic
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XAMPP is fully portable if you "install" it from ZIP. And has got both PHP4 and PHP5.

    WAMP is AFAIK able to host more versions of PHP and MySQL (but I only test it a long time ago, do not use it).

  9. #9
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,407
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I write my code in Notepad++ and the files are saved in the htdocs folder of XAMPP. You can either start XAMPP as a service or as I do start it when I need it ( not forgetting to start MySql as well if you are going to use it ). You then navigate to your folder via http://localhost/folder name

    I have used Eclipse and php completly independent of XAMPP but I could not get the hang of using it ( or Netbeans and one other IDE I forget ).
    Anyway you can have both installed and they did not affect each other and as long as you save all your code into the htdocs folder you can run it from either method.

  10. #10
    SitePoint Guru
    Join Date
    Nov 2003
    Location
    Huntsville AL
    Posts
    689
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TryingToLearn View Post
    Maybe I am not understanding the PHP setup completely, but I would like for Eclipse to build the PHP web project and everything. Does XAMPP work in Eclipse like Tomcat does for Java?
    Not really. For PHP you just put your files in a web directory and off you go. There is no configuration files etc needed. In PHP everything is transient. Each request starts everything up, does it thing and then shuts down. No Java type command objects hanging around.

    When you start Eclipse you open a workspace. You can then use the PDT plugin to create one or more PHP projects. You create your php files within a project.

    From there you have a few choices. You can copy the php files to single web htdocs directory or you can create an htdocs directory inside each project and use Apache's virtual web hosting to point the browser to it.

    You may be over analyzing things a bit. Just install xampp and eclipse and mess around. It's easy to re-install everything if something get's messed up.

  11. #11
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for all the feedback. My goal is to get my local machine setup tonight.

  12. #12
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    If you do use an installer, which it sounds as though you are going to do, make sure you spend a good hour reading the file php.ini which will at least introduce many of the settings that the installer has just set up for you.

    Even slight differences in PHP settings can create problems when you eventually try to migrate some work to another server.

    I understand everyones rush to just 'get it working', but you will be brushing past fundamental issues that will be central to understanding what the stack is doing when requests are handled.

    Reading the ini will help you over that hump.

  13. #13
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the recommendation. I will take some time and read about the php.ini.

    For what its worth, the XAMPP, Eclipse and PDT plugin installation went well last night. In about 2 hours I was able to successfully display my first helloWorld.php page.

    I do have one more question… I did not download a PHP library and I think it was included in the XAMPP installation. Is this true and if so, where is the PHP framework install at? For example, my Java JRE is installed at C:\Program Files\Java\JRE version.

  14. #14
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The php.ini file is the configuration file which is read one time when PHP starts up. If changes are made to this file, in order for the server to pick them up, the server needs to be restarted.

    In XAMPP, the php.ini files is located at:

    C:\xampp\php\php.ini

    The php.ini file lets you alter many aspects of PHP’s behavior including setting file paths and directories, changing session and database parameters, and activating extensions.

    To me, it sounds like each project would have its own unique php.ini file. The reason I am thinking this is, each project probably has its own database connection variables, etc. Is this true?

    If each project does have its own php.ini file, where would it be located in a PHP web project directory structure?

  15. #15
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,407
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    No you do not need to touch the php.ini file.

    I Create a directory in the htdocs folder for each project. The database connections will be in that folder and just consist of the username, password and database location which is normaly localhost.

    You only normaly touch the php.ini file for things like setting up an email server and installing new moduals and software.
    Last edited by Rubble; Jul 11, 2009 at 13:49. Reason: Extra text

  16. #16
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Generally each server has a php.ini file ( not talking shared hosting here ).

    But you can override some of the settings on a per-directory basis (like .htaccess) or even per-script basis using ini_set().

    What you can and cannot set is documented in the manual.

    You don't need to restart the server (the machine) just stop/start Apache, not sure if that was what you meant.

    I know you can set some db connections up in the ini file, but I have never seen that used. Most ppl fire up a PDO connection.

    You mentioned Frameworks and you can take your pick - there is no one true way.

    The other terms you'll want to get up to speed with are PEAR and PECL.

    PEAR contains libraries of PHP classes which you can install.
    PECL contains libraries of C functions which you can install which in effect extend PHP.

    You occassionally come across things that appear in one of those libraries that move their way into a PHP build, or conversely get taken out of PHP and put back into PECL (though this is rare now).

    Beware, this is only my opinion, and I am well known for getting things wrong.

    Someone will soon put me right though.

    How to quickly get info out of the online manual, and the associated user-notes:

    e.g ini_set() wots that? (RM the spaces) w w w. p h p . n e t /ini_set


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
  •