This is a sample laravel project to demonstrate some PHP and Vue JS framework functionality.
The external currency API is accessible via /currency/australian-dollars
. This will return a page which has the JSON result from the API.
The relevant files for this part are:
app/Http/Api/CurrencyApi.php
Which makes the request to the API and returns the result as JSON.app/Http/Controllers/CurrencyController.php
Which handles the calling to the currency API and returns a view to the user when accessed via the browser.tests/Feature/CurrencyTest.php
- This has the unit tests for this section.
I have chosen to implement an interface and a factory. These can be found (along with example usages in the Patterns
folder) app/Http/Patterns
.
These also have unit tests set up: tests/Unit/SquareFactoryTest.php
.
I have created a simple list of books. This list can be added to or deleted from. The navigation between these components is handled via the vue-router.
resources/js
- This containsapp.js
androuter.js
as well as thecomponents folder
.resources/views/layouts/app.blade.php
- The main application layout wrapper. This is extended by
resources/views/book/index.blade.php
which imports the Vue components.
To set the project up locally, please complete the following steps:
- Make sure your system has Node.js 10.13 or later. If you need to install NodeJS, on Ubuntu, run:
sudo apt install nodejs
To check the install succeeded, run:
node -v
This should show the currently installed NodeJS version, eg: v10.19.0
.
- You will then need to install the Node Package Manager (NPM), for Ubuntu, run the following:
sudo apt install npm
- Once NPM has been installed, clone this project from Github by running the following command:
git clone https://github.com/karstenabc/laravel-test-project.git
- Enter into the project directory:
cd laravel-test-project
- Install the projects' dependencies:
npm install
- Finally, run the development server:
npm run dev (if you have followed the above instructions)
# or
yarn dev (if your system is set up with yarn)
- Open http://localhost:8000 with your browser.
Visit http://localhost:8000/currency/australian-dollars in your browser.
Along with the other parts you can run the unit tests with php artisan test
. However, there is no web route for this part.
- Visit http://localhost:8000/ in your browser. This will show all of the books that have been saved into the local database file. These books can be deleted, and new books can be added.
- Click
Add Book
to be taken to the add book page via vue-router and fill out the details and clickAdd Book
orAll Books
to go back to viewing all of the stored books. - Click
Delete
under any book to remove it from the database.