Skip to content

Job Interview for Full Stack PHP Developer. System to make publications and comments.

Notifications You must be signed in to change notification settings

mascam97/laravel-livewire-publications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Livewire Publications Status Passing Docker build Tests

Job Interview for Full Stack PHP Developer. System to make publications and comments.

Project goal by mascam97

This was a part of technical job interviews where I completed some challenges and questions.

I decided to challenge me by working with Jetstream + Livewire - Blade (instead of Laravel UI and Vue.js) and Tailwindcss (instead of Bootstrap), because I have personal projects with these features.

Achievements 2021 🌟

  • Completed all the challenges.
  • Implemented a CRUD and dynamic components with Livewire.
  • Implemented an Event, Listener and Notification to send an email as Queue.
  • Implemented design with Tailwindcss according to Jetstream components and styles.
  • Implemented professional features like pagination, searching, flash messages, etc.
  • Implemented Testing with PHPUnit to Models, Controllers and Livewire components.
  • Fixed some bugs with testing and investigation.

Achievements 2023 🌟

  • Implemented State Pattern in comment state
  • Implemented View Model in publications
  • Optimized some queries

TODOs

  • Implement Alpine.js
  • Improve the quality code
  • Improve the code coverage

Getting Started 🚀

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites 📋

The programs you need are:

Installing 🔧

First duplicate the file .env.example as .env.

cp .env.example .env

Note: You could change some values, anyway docker-compose create the database according to the defined values.

Then install the PHP dependencies:

 docker run --rm --interactive --tty \
 --volume $PWD:/app \
 composer install

Then create the next alias to run commands in the container with Laravel Sail.

alias sail='bash vendor/bin/sail'

Note: Setting this alias as permanent is recommended.

Create the images and run the services (laravel app, mysql, redis and mailhog):

sail up

With Laravel Sail you can run commands as docker-compose (e.g. docker-compose up -d = sail up -d) and php(e.g. php artisan migrate = sail artisan migrate). To run Composer, Artisan, and Node / NPM commands just add sail at the beginning (e.g. sail npm install). More information here.

Then generate the application key.

sail artisan key:generate

Finally, generate the database with fake data:

sail artisan migrate --seed

Note: You could refresh the database any time with migrate:refresh.

And now you have all the environment in the port 80 (http://localhost/).

Note: JavaScript and CSS files are loaded in public/css and public/js, you do not need to generate it with sail npm install and sail npm run watch because there are not files that generate JavaScript and CSS like SASS or Vue files.


Testing

Backend testing

There are some test for Models and Controller, Jetstream also has its tests about its features, for Livewire components there are some tests to validate its functions and placement in some view. You can run available tests with:

sail artisan test

Advanced features

Running Queues

There is a queue generated when a publication has a new comment and an email is sent to the publication owner, to run queues execute:

sail artisan queue:listen

Note: Remember in production the better command is queue:work, explanation.

You can look the emails with MailHog, it is on the port 8025.


Built With 🛠️

Authors

Contributing

You're free to contribute to this project by submitting issues and/or pull requests, there are many Bugs you can clean.

License

This project is licensed under the MIT License.

References 📚