Skip to content

ReeceG/code-test-lumen

 
 

Repository files navigation

Process

  1. To include the subscription data, in routes/web.php changed all() to with('subscription')->get() This would include the "createdAt" and "updatedAt" fields of the subscription data, which likely aren't very useful for this, so I modified it to with('subscription:id,name,price') to only grab those columns. I initially created a controller, but decided against it when I realized that there wasn't really any logic or modifying of the data to be done, just a single request.
  2. (&3.) Created a simple view using a Laravel blade template, which routes to http://localhost:3000/app. App.js includes the elements needed for React to work without needing to set up build scripts, compile jsx, etc. which seemed overkill for a small project. Fetch the data from the API, then pass it into the App component, which sorts, flips, and renders the data as MemberRow components to a table, as well as the average price. Added a catch() to the fetch chain, which displays an ErrorBlock component to the user in case of a network error.

Notes

Including React for a project this small is obviously a bit silly, but I like working with it, it helps with the rendering of elements, and if we wanted to add interactivity (i.e. different sorting conditions) to the table it wouldn't be a chore. All-in-all this was a fun little project, I had never used Lumen or even Laravel before, but it seems to share a lot of DNA with Symfony so I picked it up quickly after flipping through the docs. I'm just glad nothing went wrong with the composer or docker commands during install, that tends to be the most painful part of a project!

Lumen PHP Framework

Build Status Total Downloads Latest Stable Version License

Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching.

Code Test: Lumen

A simple Lumen app designed to provide a basic API for our code test.

Quick start

  1. Install PHP (7.2+) or use an environment like Laravel Homestead or Docker (see below)

  2. Install composer and run composer install to install dependencies

  3. Copy the .env.example file to .env and set a random string for APP_KEY

  4. Run touch database/database.sqlite to create a development database

  5. Run php artisan migrate to migrate your development database

  6. Run php artisan db:seed to seed your development database

  7. Run php -S localhost:3000 -t public to start up the local development server

You should get JSON output from http://localhost:3000/members

Testing

Run vendor/bin/phpunit tests to run the test suite.

Docker

As an alternative to installing PHP directly, you can use the Docker files provided by Laradock to run the app and test suite.

When cloning the project, use the --recurse-submodules flag to pull down the Laradock submodule

  1. cd laradock

  2. cp .env-example .env

  3. Change NGINX_HOST_HTTP_PORT to 3000, WORKSPACE_BROWSERSYNC_HOST_PORT to 4000 and WORKSPACE_BROWSERSYNC_UI_HOST_PORT to 4001

  4. docker-compose up -d nginx

Note: This could take a few minutes on the initial build

Then connect to the Docker container using docker-compose exec workspace bash to run the setup tasks above.

Official Documentation

Documentation for the framework can be found on the Lumen website.

Contributing

Thank you for considering contributing to Lumen! The contribution guide can be found in the Laravel documentation.

Security Vulnerabilities

If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at [email protected]. All security vulnerabilities will be promptly addressed.

License

The Lumen framework is open-sourced software licensed under the MIT license.

About

Lumen API app for use in the Carney dev team code test

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 90.1%
  • JavaScript 7.2%
  • Blade 2.0%
  • Shell 0.7%