We help digital health startups, clinics, and medtech companies ideate, design, and develop custom web & mobile applications that transform the future of healthcare.
Requirements: Php >= 8.2.0 & Composer
brew install [email protected] composer
Mac OS X with brewapt-get install php8.2
Ubuntu with apt-get (use sudo if is necessary)
This step is not necessary when you use Docker.
- Docker
- Laravel Sail
- Laravel 10.X & Php 8.2
- Tools
- Clockwork Debug Bar
- Ide Helper
- Phpstan
- Php ECS
- Rector Php
- XDebug
- Single Action and Clean Controllers
- Request Classes
- Strict Mode
- Tools
- Vite
- Postcss
- Prettier
- Typescript
- React 18
- Tailwindcss 3
- Mysql 8
- Redis
- Meilisearch
- Minio
- Mailpit
- Pest Php for Backend Testing
- Coverage HTML Report
- Browser Testing with Dusk (using selenium)
- Git
- PR Template
- Issue Template
- Git Hooks with CaptainHook
-
Clone GitHub repo for this project locally:
git clone [email protected]:Light-it-labs/lightranet
-
cd into your project and create a copy of your .env file
cd lightranet cp .env.example .env
-
If you have Php installed you can install composer dependencies with sail included with
docker run --rm \ -u "$(id -u):$(id -g)" \ -v $(pwd):/var/www/html \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer install --ignore-platform-reqs
-
After that you can use laravel sail for running your project.
sail up
See more detail below.
-
When the app is running, into the bash container (
sail bash
) you can use the following commands:php artisan key:generate php artisan storage:link php artisan ide-helper:generate php artisan migrate --seed
You need nvm installed in your machine. https://github.com/nvm-sh/nvm#install--update-script
For frontend environment you need install npm dependencies with npm install
and after that to compile assets for Frontend SPA in local you can run: npm run dev
or npm run watch
In production environment is necessary run npm run production
-
Install npm dependencies:
nvm use npm install
-
Run the app:
npm run dev
You must activate the hooks in your local git repository. To do so, just run the following command.
vendor/bin/captainhook install
Executing this will create the hook script located in your .git/hooks directory, for each hook you choose to install while running the command. So now every time git triggers a hook, CaptainHook gets executed.
If you don't have PHP installed locally or you have installed a different version, you can use Docker to execute CaptainHook. To do so you must install the hooks a bit differently.
vendor/bin/captainhook install --run-mode=docker --run-exec="docker exec CONTAINER_NAME"
You can choose your preferred docker command e.g.:
docker exec MY_CONTAINER_NAME
docker run --rm -v $(pwd):/var/www/html MY_IMAGE_NAME
docker-compose -f docker/docker-compose.yml run --rm -T MY_SERVICE_NAME
If you want to know more you can see de documentation in the official page https://captainhookphp.github.io/captainhook/
We use Laravel Sail, is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application without requiring prior Docker experience.
By default, Sail commands are invoked using the vendor/bin/sail
script that is included with all new Laravel applications:
However, instead of repeatedly typing vendor/bin/sail to execute Sail commands, you may wish to configure a Bash alias that allows you to execute Sail's commands more easily:
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
sail up
To start all the Docker containers in the background, you may start Sail in "detached" mode:
sail up -d
To stop all of the containers, you may simply press Control + C to stop the container's execution. Or, if the containers are running in the background, you may use the stop command:
sail stop
# Running Artisan commands locally...
php artisan queue:work
# Running Artisan commands within Laravel Sail...
sail artisan queue:work
# Executing PHP Commands
sail php script.php
# Executing Composer Commands
sail composer require laravel/sanctum
# Running Tests
sail test
# Running with Coverage
sail composer test
For more info https://laravel.com/docs/10.x/sail
Run: composer fixer
and execute php cs, php cs fixer, php stan and rector.
Read https://lightit.slite.com/app/docs/rd0tnuQ5w
To run all test and generate report coverage you can use:
sail composer test
In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.
You can see the report open index.html in the reports folder.
If you want to run Dusk test, first you need compile files with vite build
and after that you can use sail dusk
for running browser test.
Important: make sure the vite server is not running
PHPStorm configuration
First open Preferences > PHP > Debug.
Just to make sure we will be able to catch the interrupt from xdebug, we just need to check the “Break at first line in PHP scripts”.
Next, we need to turn on Run > Start Listening for PHP Debug Connection
.
Finally, let’s configure the server configuration in Preferences > PHP > Servers
Couple of things to ensure
- “Name” must be identical to the one set in the docker-compose.yml
- Check “Use path mappings”
- Map your local project folder to the docker folder. (
/var/www/html
)
That’s it. Create a breakpoint somewhere in the project and check that all is working. Once everything is working, you can remove the “Break at first line in PHP scripts”.
https://laravel.com/docs/10.x/sail#debugging-with-xdebug
The web page is using a clockwork as debugbar, it is similar to debugbar from laravel, The most important difference between clockwork and debugbar (standard) is that clockwork only display information in console so, you need to open console (F12)
Full documentation of clockwork in this link.
It is mandatory to install plugin of clockwork in your browser check this link
The next list contains the HTTP codes returned by the API and the meaning in the present context:
- HTTP 200 Ok: the request has been processed successfully.
- HTTP 201 Created: the resource has been created. It's associated with a POST Request.
- HTTP 204 No Content: the request has been processed successfully but does not need to return an entity-body.
- HTTP 400 Bad Request: the request could not been processed by the API. You should review the data sent to.
- HTTP 401 Unauthorized: When the request was performed to the login endpoint, means that credentials are not matching with any. When the request was performed to another endpoint means that the token it's not valid anymore due TTL expiration.
- HTTP 403 Forbidden: the credentials provided with the request has not the necessary permission to be processed.
- HTTP 404 Not Found: the endpoint requested does not exist in the API.
- HTTP 422: the payload sent to the API did not pass the validation process.
- HTTP 500: an unknown error was triggered during the process.
Please refer to https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for reference
To access services in local environment with host aliases, add the following aliases in the /etc/hosts
file.
-
Edit the file with the following command:
sudo nano /etc/hosts
-
Paste the following hosts aliases:
127.0.0.1 lightranet.test 127.0.0.1 db 127.0.0.1 s3 127.0.0.1 redis 127.0.0.1 mailpit
- php: 8.2.x
- php ini configurations:
upload_max_filesize = 100M
post_max_size = 100M
- These numbers are illustrative. Set them according to your project needs.
For reviewers: Emojis can be added to comments to call out blocking versus non-blocking feedback.
E.g: Praise, minor suggestions, or clarifying questions that don’t block merging the PR.
🟢 Nice refactor!
🟡 Why was the default value removed?
E.g: Blocking feedback must be addressed before merging.
🔴 This change will break something important
Blocking | 🔴 ❌ 🚨 | RED |
Non-blocking | 🟡 💡 🤔 💭 | Yellow, thinking, etc |
Praise | 🟢 💚 😍 👍 🙌 | Green, hearts, positive emojis, etc |