This exercise is designed to assess how you approach tasks required in your position as an intermediate PHP developer at silverorange. We are interested to see how you work as well, as what your final results are; include useful Git commit messages and comments where you think your code may be unclear.
Please do not include your name or any other self-identifying information in code or commit messages as silverorange will anonymize your work before reviewing.
Using the provided basic web framework, make the following changes to the
/checkout
page. For this part of the exercise we are interested in HTML and
CSS only—no functionality is required. No mockups are provided, so work to
make changes fit with the existing visual page design:
- Change the multi-line Street Address field into Line 1 and Line 2 fields. The Line 2 field should be optional.
- Add a checkbox and the following text below the Order Summary section:
With our “Rise & Shine” beta program, you get early access to new features, but they may not always work perfectly. You can change your beta preference at any time after you join.
- Add a picture of the product into the order summary. A high resolution image
is provided in
highres-assets/product.jpg
. - Add a submit button to the form. The button should have the title Place Order.
The template for the checkout page is in src/Templates/Checkout.php
. The
styles for the page are in assets/index.css
.
Using the same provided basic web framework, and data fixtures for authors and posts that are provided:
- Write an importer in PHP that imports a list of post files (examples are
provided in the
data
folder) into the database. - Update
src/Controller/PostDetails.php
to load a published post from the database with the specified id. Update thesrc/Template/PostDetails.php
template to render the post content (title, body, author) as HTML. The post body is formatted as Markdown and the HTML should include the formatted Markdown. - Update the
src/Controller/PostIndex.php
to load all published posts from the database in reverse chronological order. Update thesrc/Template/PostIndex.php
template to render ths list as HTML. Include the post titles and authors in the output. Make clicking a post go to the post details.
The provided basic web framework is a guideline—feel free to adapt it however you like to achieve the tasks above.
See below for instructions on how to run the test database.
You may use any currently supported version of PHP. If you are using macOS, installing PHP via brew is recommended. The default PHP provided by macOS can only connect to MySQL.
Docker Compose is an easy option to get a local database running, but it is not required.
Please use PSR-12 and PSR-4 for your code. The PHPCS tool can be used to check your code.
The project is set up to lint your code using:
composer run lint
Pease use the Composer tool for dependency management. You can use any 3rd-party libraries as necessary or as desired in order to achieve the tasks.
Your commit history is important to us! Try to make meaningful commit messages that show your progress. Remember to not include your name or any other self-identifying information in your commit messages.
Provided is an extremely basic PHP web framework. The provided web framework runs using PHP’s built-in web server using using the command:
composer run start
You can then access the application on port 8000. The following links can be used to test:
- http://localhost:8000 - this will verify the application is running.
- http://localhost:8000/checkout - the page to edit for part 1 of the exercise.
- http://localhost:8000/posts - the posts index page.
- http://localhost:8000/posts/6ec246b1-ad09-4e03-8573-21e2e779856c - this should load a post once the posts are imported and the application is updated.
- http://localhost:8000/asdfghjk - this should show a not-found page.
Here is an overview of the files and folders that make up the framework:
Controller/
- these classes are simple route controllers. They can load data, set request-specific data in a context object, and pass it to templates.Template/
- these classes contain arender()
method that takes a context object and returns a string of HTML. The context object can contain arbitrary data to pass to the template.Model/
- simple classes that could represent data from the database. You may use these if you find them helpful.App.php
- this is the main class that runs the framework. Therun()
method loads an appropriate controller for the current request. The controller renders the template and the application sends the content as HTTP response (aka it echos the content).
You may use MySQL, MariaDB, PostgreSQL, or SQLite for this exercise.
The provided SQL files will run in PostgreSQL. You can use the provided Docker Compose configuration to run a local instance of PostgreSQL using:
docker compose up --detach
The Docker container is accessible externally using the following properties:
- host:
localhost
- port:
5532
- database:
silverorange
- user:
silverorange
- password:
silverorange
When the database is running, you can import the provided tables and fixtures by running:
docker compose exec -- db psql silverorange silverorange < sql/authors.sql
docker compose exec -- db psql silverorange silverorange < sql/posts.sql
If you want to reset your database, run:
docker compose down --volumes
docker compose up --detach
For other databases, the provided SQL sources in the sql/
folder may need
modification. You may use Docker Compose or any other method of running a local
database.
The DSN string in src/Config.php
may need to be modified if you use a
different database or do not use PostgreSQL with Docker Compose.