/betterstack-project

[interview assignment] PHP Test Project

Primary LanguagePHP

PHP Test Project

Table of Contents

Description

This is a very simple one-page application consisting of a single table and a form for creating new rows. To make it a little more complicated, we have written a 'framework' you have to use. Below is a set of simple tasks to perform. Please write a production-ready code.

Installation ⚙️

Database

  1. Connect to MySQL:
$ mysql -u root -p
  1. Create a new MySQL database:
CREATE DATABASE `php_test_project`;
  1. Import database/schema.sql into your database:
$ mysql -u root -p php_test_project < database/schema.sql

Application

  1. Clone the repository
  2. Run composer install to install dependencies.
  3. Database credentials: Copy .env.example to .env and update the database credentials.
  4. Run php -S localhost:8000 to start the built-in Development Server.

Tasks to perform

  1. Style the page using Bootstrap or Tailwind
  • Every other table row should be highlighted. [done]
  • Use Bootstrap’s form-horizontal or equivalent to style the form. [done]
  • Please make any other styling changes based on your preferences to make the interface look presentable. [done as much as bootstrap 3.0.0 allows]
  1. Add a validation of new records. [done]
  2. Create a JS functionality to filter rows by city. [done]
  3. Implement submission of the form using AJAX. [done]
  4. Add a phone number column to the table. [done]
  5. Please deploy the project to any freehosting and send us the production link. [done]

Other Changes Made

Apart from all the tasks mentioned in the instructions, I have also:

  • Removed the short open tags from the code in views/index.php because they are not recommended according to the PHP documentation and require manual enabling in PHP 8.3.8.
  • Switched to using Environment Variables for security reasons and easier deployment, as you requested for production-ready code.
  • Previous import paths caused issues in the Docker container (different root path). I've updated them for a smoother experience.

Notes

  • I've kept and utilized all base dependencies, nothing was updated since it's a Legacy test project and in the real life scenario I would had to discuss it thoroughly with the team before making any changes.
  • Minimal changes were made to the existing Framework's code. I've only added the necessary code to fulfill the tasks and make the application production-ready.
    • Phone numbers related changes.
    • Removed short open tags.
    • Updated import paths (for Docker).
    • Switched to using Environment Variables.

Deployment Information

The project is currently deployed on Heroku, with the MySQL database residing on Railway. Ideally, a unified hosting solution would have been preferred, with Railway being the primary choice. However, due to limitations in their PHP support, this was not possible.

Thank you

Thank you for the opportunity to work on this project. I really enjoyed working on it and I hope you like it. If you have any questions or need any further information, please feel free to reach out to me. I'm looking forward to hearing from you soon! 😊