TechBuzzPro

CodeIgniter Setup with NetBeans and XAMPP on Windows

· 6 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To set up CodeIgniter with NetBeans and XAMPP on Windows, install XAMPP and start Apache and MySQL, download CodeIgniter 3 or 4, place it in the XAMPP htdocs folder, then open the project in NetBeans and configure a run configuration pointing to the public folder or index.php. This gives you a local PHP development environment with a browser preview and database access. You need Windows, an internet connection, and basic familiarity with file paths. The steps below use CodeIgniter 4 (the current version) and XAMPP's default install path; menu labels may vary slightly by version.

What You'll Need

  • A Windows PC with at least 2 GB free disk space.
  • XAMPP for Windows (download from apachefriends.org).
  • NetBeans IDE (download from netbeans.apache.org; the PHP bundle includes HTML/CSS/JS support).
  • CodeIgniter 4 (download from codeigniter.com) or CodeIgniter 3 if you maintain an older project.
  • A plain text editor is optional; NetBeans handles PHP editing.
  • Administrator rights to install software and start services.

Step-by-Step

  1. Install XAMPP. Run the installer and accept the default location C:\xampp. Avoid paths with spaces or non-English characters. At the end, leave the "Start Control Panel" option checked.
  2. Start Apache and MySQL. In the XAMPP Control Panel, click Start next to Apache and MySQL. Both should turn green. If Apache fails, see Troubleshooting below.
  3. Confirm the web server works. Open a browser and go to http://localhost. You should see the XAMPP dashboard. If you see it, Apache is serving files from C:\xampp\htdocs.
  4. Download CodeIgniter. Get the latest CodeIgniter 4 zip from the official site. Extract it so the framework files sit directly in a folder such as C:\xampp\htdocs\ci4. Inside that folder you should see app, public, system (or vendor for CI4), and other files.
  5. Set the base URL. Open app\Config\App.php in a text editor and set public $baseURL = 'http://localhost/ci4/public/';. This tells CodeIgniter where it lives so links and redirects work.
  6. Create a database (optional but common). In the XAMPP Control Panel, click MySQL > Admin to open phpMyAdmin. Create a database, for example ci4db. Then edit app\Config\Database.php with the hostname localhost, username root, empty password (default XAMPP), and your database name.
  7. Open the project in NetBeans. Launch NetBeans, choose File > New Project > PHP > PHP Application with Existing Sources. Set the sources folder to C:\xampp\htdocs\ci4. Set the project URL to http://localhost/ci4/public/ and the index file to index.php. Finish the wizard.
  8. Configure the run configuration. Right-click the project, choose Properties > Run Configuration. Ensure the Project URL matches the base URL above. If NetBeans asks for a local web server, choose "Local Web Site" and point the document root to C:\xampp\htdocs.
  9. Run the project. Press F6 or click Run. NetBeans opens your default browser at the project URL. You should see the CodeIgniter welcome page. If you see a directory listing or a 404, check the base URL and that you are pointing at the public folder.
  10. Edit and test. Open app\Controllers\Home.php in NetBeans, change the welcome message, save, and refresh the browser. Changes appear immediately because PHP runs on each request.

Common Mistakes

  • Pointing the browser at http://localhost/ci4/ instead of http://localhost/ci4/public/. CodeIgniter 4 expects the public folder as the document root.
  • Leaving the base URL as the default placeholder, which breaks redirects and asset links.
  • Extracting CodeIgniter into a folder with spaces (for example "My Projects"), which can cause path issues in some tools.
  • Forgetting to start MySQL before opening phpMyAdmin, resulting in a connection error.
  • Using the wrong database password. XAMPP's default MySQL user is root with no password; if you set one during install, use it in Database.php.
  • Installing NetBeans without the PHP bundle, so PHP project types do not appear.

Tips

  • Keep the XAMPP Control Panel open while developing so you can restart Apache or MySQL quickly.
  • Use NetBeans' PHP debugger only if you need it; basic development works without extra configuration.
  • Back up app\Config before editing, since it holds your base URL and database settings.
  • If you use CodeIgniter 3, the folder layout differs: the application folder sits at the root and the entry point is index.php in the project root, not a public folder.
  • Create a separate database per project to avoid table name clashes in phpMyAdmin.

Troubleshooting

Apache will not start. Another program is likely using port 80, often another web server or a Windows service. In the XAMPP Control Panel, click Config next to Apache and change the listen port to 8080, then use http://localhost:8080 in the browser and update the base URL to match. Also check that no other XAMPP instance is running.

MySQL will not start. Port 3306 may be in use. Change the MySQL port in the XAMPP config, or stop the conflicting service. If the data folder is corrupted, back it up before making changes.

Blank page or 500 error. Enable error display temporarily by setting the environment to development in .env (rename env to .env and set CI_ENVIRONMENT = development). Check the logs in writable\logs for the actual message.

404 on every page except the home page. The base URL is wrong or URL rewriting is not configured. For a quick fix, use the index.php URL style: http://localhost/ci4/public/index.php/controller/method. For clean URLs, enable the mod_rewrite module in Apache and use the included .htaccess file.

NetBeans cannot find the project URL. Recheck the Run Configuration: the project URL must include the public folder and a trailing slash. Also confirm Apache is running before pressing Run.

Database connection refused. Confirm MySQL is running, the hostname is localhost, and the database name in Database.php matches the one you created in phpMyAdmin.

Frequently Asked Questions

Do I need Composer to install CodeIgniter?

No. You can download the zipped release from the official site and extract it. Composer is optional and mainly useful for managing dependencies.

Can I use CodeIgniter 3 with these steps?

Yes, but the folder layout and entry point differ. In CodeIgniter 3, the main files sit at the project root and the entry point is index.php there, not in a public folder. Set the base URL in application\config\config.php.

Why does the welcome page show a directory listing?

You are probably opening the project root instead of the public folder. Point the browser and NetBeans run configuration at http://localhost/ci4/public/.

Is XAMPP required, or can I use another server?

XAMPP is convenient because it bundles Apache, MySQL, and PHP. Any local Apache/MySQL/PHP stack works, but the paths and control panel differ.

How do I change the port if 80 is already in use?

In the XAMPP Control Panel, open the Apache config and change the Listen port, then update your base URL and NetBeans project URL to include the new port.

Where do I put my own PHP files?

In CodeIgniter 4, controllers go in app\Controllers, views in app\Views, and models in app\Models. Do not place application code directly in the public folder except assets like CSS and images.