A simple PHP application that automatically performs CRUD (Create, Read, Update, Delete) operations with a PostgreSQL database, designed for testing deployment on Render.com using Docker.
- PHP backend with PostgreSQL database
- Automatic CRUD operations on each page load
- Detailed operation results display
- Responsive design with CSS
- Client-side enhancements with JavaScript
- Docker containerization for easy deployment
- PHP 7.4 or higher
- PostgreSQL 12 or higher
- Web server (Apache, Nginx, etc.)
- Clone this repository to your local machine
- Create a PostgreSQL database for the application
- Configure your web server to serve the application
- Set the following environment variables in the
.envfile:DB_HOST: PostgreSQL host (default: localhost)DB_PORT: PostgreSQL port (default: 5432)DB_NAME: Database name (default: postgres)DB_USER: Database usernameDB_PASSWORD: Database password
- Access the application through your web browser
For quick testing, you can use PHP's built-in web server:
php -S localhost:8972Then visit http://localhost:8972 in your browser.
You can also run the application using Docker:
# Build the Docker image
docker build -t php-postgres-crud-test .
# Run the container
docker run -p 8972:80 --env-file .env -d php-postgres-crud-testThen visit http://localhost:8972 in your browser.
- Log in to your Render.com account
- Go to the Dashboard and click on "New +"
- Select "PostgreSQL"
- Configure your database:
- Name: postgres-crud-test-db
- Database: postgres
- User: Choose a username
- Region: Select the region closest to your users
- PostgreSQL Version: Choose the latest version
- Click "Create Database"
- Once created, note the connection details (host, port, database name, username, password)
- From the Render.com Dashboard, click on "New +"
- Select "Web Service"
- Connect your repository or upload your code
- Configure your web service:
- Name: php-postgres-crud-test
- Environment: Docker
- The Dockerfile is already included in the repository
- The environment variables will be automatically set if you use the Blueprint feature with the included
render.yamlfile - Click "Create Web Service"
For easier deployment, you can use Render's Blueprint feature:
- Push your code to a Git repository
- In Render.com, go to "Blueprints" and click "New Blueprint Instance"
- Connect to your repository
- Render will automatically set up the web service and database as defined in the
render.yamlfile
Once deployed, you can test the application by:
- Visiting the URL provided by Render.com
- The page will automatically perform CRUD operations on each load
- Check the "Automatic CRUD Test Results" section to see the results of each operation
- Verify that the database connection is successful
If you encounter issues with the database connection:
- Verify that your environment variables are set correctly
- Check if your IP is allowed to access the PostgreSQL database
- Ensure that the PostgreSQL service is running
- Check the Render.com logs for any error messages
This project is open-source and available under the MIT License.