Movie Ticket System API Documentation (PHP Version)
# Movie Ticket System API Documentation (PHP Version)
## Introduction
The Movie Ticket System is a comprehensive PHP-based backend application that enables users to browse movies, purchase tickets, and process payments via M-Pesa. This system is designed as a single-file PHP application that handles all aspects of ticket management and payment processing.
Built with modern PHP practices, this system provides a RESTful API that can be integrated with any frontend technology. It uses PDO for database connectivity, ensuring secure and efficient data handling. The M-Pesa integration makes it particularly suitable for the Kenyan market, but it can be adapted for other payment gateways.
Key features include:
- Movie management (add, retrieve)
- Ticket purchasing
- M-Pesa payment integration with STK Push
- Payment status tracking
- Ticket availability management
## Getting Started
### Prerequisites
- PHP 7.4 or higher
- MySQL 5.7 or higher
- Apache or Nginx web server
- SSL certificate (for production)
- M-Pesa developer account (for Safaricom API access)
### Installation
1. Clone the repository:
```bash
git clone
github.com
cd mpesa_movie_system_php
```
2. Create a MySQL database:
```sql
CREATE DATABASE movie_tickets;
```
3. Import the database schema (use the provided `database.sql` file):
```bash
mysql -u username -p movie_tickets 'localhost',
'dbname' => 'movie_tickets',
'username' => 'your_username',
'password' => 'your_password',
'charset' => 'utf8mb4'
];
```
- Update the M-Pesa configuration with your Safaricom credentials:
```php
$mpesa_config = [
'base_url' => '
sandbox.safaricom.co.ke',
'consumer_key' => 'your_consumer_key',
'consumer_secret' => 'your_consumer_secret',
// ... other settings
];
```
5. Deploy to your web server:
- Copy the `index.php` file to your web server's document root or a subdirectory
- Ensure the web server has write access to create or modify the database
6. Set up your …