From Localhost to Live
You've built a complete, feature-rich web application on your local machine. The final step in the development process is **deployment**—moving your project from your local XAMPP environment to a live web server where anyone on the internet can access it. This module will walk you through the general steps required to deploy a PHP and MySQL application.
Step 1: Pre-Deployment Checklist
Before uploading your files, it's important to prepare your application for a live environment.
- Error Reporting: On your local machine, it's helpful to see all errors for debugging. On a live server, you should turn off detailed error display to users for security. You can set `error_reporting(0);` and `ini_set('display_errors', 0);` in a main configuration file. Errors should be logged to a file on the server instead.
- Configuration File: Your database credentials (`DB_USER`, `DB_PASSWORD`, etc.) will be different on the live server. It's best practice to have these in a single, secure configuration file (`includes/db.php` in our case) that is easy to update.
- Code Cleanup: Remove any test data, unnecessary comments, or debugging code (`var_dump`, `echo`, etc.) from your project.
Step 2: Exporting Your Local Database
You need to transfer the structure and data of your database from your local machine to the live server.
- Open phpMyAdmin on your local server (
http://localhost/phpmyadmin
). - Select your `bakery_db` database from the left sidebar.
- Click on the "Export" tab at the top.
- Choose the "Quick" export method and make sure the format is set to "SQL".
- Click the "Go" button. This will download a `.sql` file to your computer. This file contains all the commands needed to recreate your database and its data.
Step 3: Setting Up the Live Server
This process involves a hosting provider. For a PHP/MySQL application, a standard shared hosting plan is usually sufficient to get started.
- Upload Files: Use an FTP (File Transfer Protocol) client like FileZilla to connect to your web host. Upload all the files and folders of your `bakery-management-system` project into the `public_html` (or `www`) directory on your server.
- Create Live Database: Log in to your hosting control panel (like cPanel). Find the "MySQL Databases" tool. Create a new database, a new database user, and assign that user to the database with full privileges. Make sure to note down the database name, username, and password.
- Import Database: Open phpMyAdmin on your live server (usually accessible from the control panel). Select your newly created database, click the "Import" tab, choose the `.sql` file you exported earlier, and click "Go".
- Update Connection Details: On the live server, edit your `includes/db.php` file and replace the local database credentials with the new live database credentials you just created.
Step 4: Final Testing and What's Next?
Navigate to your domain name in a web browser. Your Bakery Management System should now be live! Thoroughly test every feature:
- Can you register and log in?
- Are all CRUD operations for products, categories, and customers working?
- Can you place an order through the POS system?
- Are the reports and charts loading correctly?
Congratulations! You have successfully built and deployed a full-stack web application. You now have a powerful portfolio piece and a solid foundation in PHP, MySQL, and modern web development practices. From here, you can continue to add more features, such as email notifications for orders, more detailed analytics, or a customer-facing storefront.