Skip to content

Monika171/Book-Planet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Book Planet

Website Link: https://the-book-planet.000webhostapp.com/

A catalogue where all the book information can be seen and can be also exported as CSV and XML. There is a search box for quicker access and the list can also be sorted. One can even add a new book information (title & author), update the same if required and delete book info.

Getting Started

Prerequisites

Setup

  1. Clone the repository.
  2. Start the containers by running docker-compose up -d in the project root.
  3. Install the composer packages by running docker-compose exec laravel composer install.
  4. Access the Laravel instance on http://localhost (If there is a "Permission denied" error, run docker-compose exec laravel chown -R www-data storage).

Note that the changes you make to local files will be automatically reflected in the container.

Persistent database

If you want to make sure that the data in the database persists even if the database container is deleted, add a file named docker-compose.override.yml in the project root with the following contents.

version: "3.7"

services:
  mysql:
    volumes:
    - mysql:/var/lib/mysql

volumes:
  mysql:

Then run the following.

docker-compose stop \
  && docker-compose rm -f mysql \
  && docker-compose up -d

Usage

Database Setup

This app uses MySQL.

Migrations

  1. To access the running container (in this case “assignment01-laravel”), in the project root, run:
docker exec -it assignment01-laravel bash
  1. To create all the necessary tables and columns, run the following
php artisan migrate

Seeding The Database

To add the dummy titles and author, run:

php artisan db:seed

Running the tests

  1. To access the running container (in this case “assignment01-laravel”), in the project root, run:
docker exec -it assignment01-laravel bash
  1. Always clear configuration cache before running tests:
php artisan config:clear
  1. Run PHPUnit tests by:
./vendor/bin/phpunit

This should look like the image below:

Deployment

Hosting over InfinityFree

  1. Sign up or Log in.

  2. Navigate to account section called Hosting Accounts, and Create Account where subdomain and domain extension will be registered based on availability.

  3. Click on account created and go to the Control Panel. Approve and proceed.

  4. In DATABASES click on MySQL Databases and create a database.

  5. Download and open FileZilla (from Free FTP Software in cpanel).

    • Inside the application, go to File and create a New site from Site Manager with cpanel account FTP HostName, Port 21, FTP Username, Logon Type Normal and FTP Password.
      • Please reset FTP password in case it doesn’t work the first time.
  6. After successful connection, directory / should appear, which has htdocs inside it.

  7. Inside htdocs, create a new directory (for example say: laravel).

  8. Go to the laravel project to be deployed on the left.

  9. Upload the contents of the public directory of the project to htdocs on the right and rest of the contents except 'public' (and '.git' if exists) directory to that new directory which was created in step 7 (‘laravel’ in this example).

  10. Once uploaded, go to control panel again from step 3.

  11. Click on Online File Manager in FILES and then htdocs. Edit and update the paths in index.php file for new folder name (for example here laravel)
    Example below:
    Before:

    __DIR__.'/../bootstrap/app.php'
    

    After:

    __DIR__.'/laravel/bootstrap/app.php'
    
  12. Delete config.php (if exists) from /htdocs/laravel/bootstrap/cache.

  13. Update contents of .env file inside /htdocs/laravel with the right data for db host, port, database name, username and password which were created earlier.

  14. From local environment database export all tables.

  15. In cpanel, go to MySQL Databases in DATABASES again and click on Admin. Click on Import from top toolbar and select the exported file from the previous step.

  16. The laravel project should work now.

Hosting over 000webhost

  1. Sign up or Log in.

  2. Create a new website.

  3. Click on Manage.

  4. In FILES click on File Manager.

  5. Upload compressed form of the local laravel project and Unzipper php in public_html.

  6. Go to https://<website-name>.000webhostapp.com/unzipper.php.

  7. Select the right laravel project compressed file and click on Unzip Archive.

  8. Move unzipped contents of laravel project to '/'.

  9. Delete public_html directory and rename current public to “public_html”.

  10. In app/providers add the following to AppServiceProvider.php:

      public function register(): void
       {
         $this->app->bind('path.public', function(){
             return base_path('public_html');
         });
       }
    
  11. Go to .env file and copy APP_KEY after ‘base64:’

  12. Navigate to /config/app.php. Paste and save the previously copied value as:
    'key' => env('APP_KEY', base64_decode(‘copied_APP_KEY_value’))

  13. From local project environment database export all tables.

  14. In the website dashboard, scroll down to DATABASES and click on MySQL Databases to Create New Database.

  15. In Manage Database, from the newly created database, click on PhpMyAdmin on the right.

  16. Click on Import from top toolbar and select the previously exported file.

  17. Update the .env file with all the new details such as:
    DB_HOST, DB_DATABASE, DB_USERNAME and DB_PASSWORD.

  18. Visit the created website again and if everything is working as it should, in .env file, make APP_DEBUG=false.

App Info

Built With

Version

1.0.0

Author

Monika Rabha