Clone project run composer install
BookControlle
Clone project run composer install
BookController is lo
Clone project run composer install
BookController is located in app/Http/BookController.php
Routes is located in routes/api.php Model is located Models/Book.php
This project is a Laravel-based web service for managing a library's book inventory. It allows clients to add new books and retrieve details about existing books using XML for data exchange.
- PHP >= 7.4
- Composer
- Laravel 8 or later
- MySQL or another supported database
-
Clone the repository:
git clone https://github.com/agabaandre/book_inventory.git cd library-book-inventory
-
Install dependencies:
composer install
-
Create a copy of the
.env
file:cp .env.example .env
-
Configure your
.env
file with your database credentials:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database DB_USERNAME=your_username DB_PASSWORD=your_password
-
Generate an application key:
php artisan key:generate
-
Run database migrations:
php artisan migrate
-
Start the development server:
php artisan serve
-
Serve the HTML client:
- Save the
add-book.html
file in thepublic
directory of your Laravel project. - Access the client through
http://localhost:8000/add-book.html
if using Laravel's built-in server.
- Save the
app/Http/Controllers/BookController.php
: Controller handling book-related requests.app/Models/Book.php
: Eloquent model representing a book.database/migrations/xxxx_xx_xx_create_books_table.php
: Migration file for creating the books table.storage/schemas/book-schema.xsd
: XML Schema definition for book data.public/add-book.html
: HTML client for adding and retrieving books.
-
Open the HTML client in your browser:
http://localhost:8000/add-book.html
-
Fill in the book details in the "Add New Book" form and click "Add Book".
-
Open the HTML client in your browser:
http://localhost/client_app/client.html
-
Enter the ISBN of the book in the "Get Book Details" form and click "Get Book Details".
- URL:
/add-book
- Method:
POST
- Content-Type:
application/x-www-form-urlencoded
- Parameters:
xml
(string): XML representation of the book data.
Example Request:
<book>
<title>Example Book Title</title>
<author>Author Name</author>
<isbn>1234567890</isbn>
<publicationYear>2024</publicationYear>
<publisher>Example Publisher</publisher>
</book>
- URL:
/book/{isbn}
- Method:
GET
- Response: XML representation of the book data.
Example Response:
<book>
<title>Example Book Title</title>
<author>Author Name</author>
<isbn>1234567890</isbn>
<publicationYear>2024</publicationYear>
<publisher>Example Publisher</publisher>
</book>
This project is open-source and available under the MIT License.