Lesson 2: Setting Up the Environment

2.1 Installing XAMPP/WAMP/MAMP

  • What is XAMPP/WAMP/MAMP?
    • XAMPP: Cross-platform Apache, MySQL, PHP, Perl.
    • WAMP: Windows-based server stack.
    • MAMP: macOS-based stack.
  • Steps to Install XAMPP:
    1. Download from the official XAMPP website.
    2. Run the installer and follow the prompts.
    3. Start the Apache and MySQL services from the XAMPP Control Panel.
  • Verifying Installation:
    • Open a browser and visit http://localhost.
    • You should see the XAMPP dashboard.

2.2 Setting Up VS Code/PhpStorm for PHP

  • Visual Studio Code (VS Code):
    1. Download and install from the VS Code website.
    2. Install the PHP Intelephense extension for code suggestions.
    3. Set up the PHP executable path in VS Code settings.
  • PhpStorm:
    1. Download and install PhpStorm from JetBrains.
    2. Configure your project by pointing to the PHP interpreter and web server.

2.3 Running Your First PHP Script

  1. Create a file named index.php in the XAMPP htdocs directory (or the equivalent for WAMP/MAMP).
  2. Add the following code:
  3. echo "Hello, World!";
  4. Open a browser and navigate to http://localhost/index.php.
  5. You should see Hello, World! displayed on the screen.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *