Skip to content

Commit

Permalink
Refactor configuration setup for command prohibition
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithDennis committed Oct 30, 2024
1 parent e02cb15 commit 1a1a810
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 63 deletions.
86 changes: 29 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,48 @@ Kickstart your project and save time with Larament! This time-saving starter kit
> [!NOTE]
> This starter kit includes **Laravel 11** and **FilamentPHP 3** with some packages that improve the development experience. This will not contain any bloated features or unnecessary packages. If you want to add more features, you can do so by installing the necessary packages.
## Configuration

## Filament Configuration and Extra's
### Security and Testing
- A handfull of [PESTPHP](https://pestphp.com/docs/installation) test cases are included for testing.
- [ShouldBeStrict](https://laravel-news.com/shouldbestrict) is enabled on non-production environments.
- [Prohibit destructive commands](https://laravel-news.com/prevent-destructive-commands-from-running-in-laravel-11) in production environments.
- Archtest is included for architectural testing.
- PHPStan is included for static analysis.
- Laravel debugbar is included for debugging.

### Quality of Life
- A custom login page autofills email and password with seeded data, streamlining local testing.
- A custom password generator action is available on the user profile and user resource pages.
- Global user search includes email addresses in results for better user discovery.
- All component labels are automatically translatable, eliminating the need for `->translateLabel()` in individual components.
- The `composer review` command runs a series of tests to ensure the codebase is clean and ready for deployment.
- Helper file is included for custom helper functions.

### Design
- The Filament Panel's primary color is set to blue.
- Single Page Application (SPA) mode is enabled by default, providing faster and smoother user experiences.
- A custom login page autofills email and password with seeded data, removing the need for manual typing in local testing.
- Single Page Application (SPA) mode is enabled by default for a faster, smoother user experience.
- Global search keybinding is preset to `CTRL + K` or `CMD + K` (for macOS) for quick access to search functionality.
- PEST test cases for the `UserResource`, `Login`, and `Profile` pages.
- The global user search includes email addresses in the search results for better user discovery.
- A custom password generator action is available on the user profile and user resource pages.
- A custom profile page utilizes the password generation feature for streamlined user management.
- A ready-to-use custom theme includes a sidebar separator for better UI organization.
- Password reset functionality is available on the login page for easy password recovery.
- All component labels are automatically translatable, so there’s no need to add `->translateLabel()` to individual components.
- Archtest is included for architectural testing.
- A ready-to-use FilamentPHP [custom theme](https://filamentphp.com/docs/3.x/panels/themes#creating-a-custom-theme) that alos includes a sidebar separator.
- A custom profile that includes a password generator.

## Default User (Local)
By default, the first user will be created based on the credentials setup in the `.env` file. If you want to change the default user after running the seeders, you can update the `DEFAULT_USER_EMAIL` and `DEFAULT_USER_PASSWORD` in the `.env` file and run the seeders again.
## Default User
The default user is seeded with the following credentials:

```dotenv
DEFAULT_USER_EMAIL="[email protected]"
DEFAULT_USER_PASSWORD="password"
```

## Composer Review
A composer script `composer review` is available to run the following commands to ensure the codebase is clean and ready for deployment.

```bash
composer review
```

The script will run the following commands:

```bash
./vendor/bin/pest --parallel
./vendor/bin/pint
./vendor/bin/phpstan analyse
```
## [Helpers](https://laravel-news.com/creating-helpers)
I've set up a Helper file for you to use in your Laravel app. You can find it at `app\Helpers.php`. This file is ready for you to add your custom helper functions, which Composer will automatically include in your project.

## [Should Be Strict](https://laravel-news.com/shouldbestrict)
This boilerplate has `shouldBeStrict` in the boot method of the `AppServiceProvider`. This setting will stop lazy loading (prevents N+1 query issues), silently discarding attributes, and prevent accessing missing attributes. This will help you catch errors early and improve the quality of your code.

## Packages

### [timokoerber/laravel-one-time-operations](https://github.com/TimoKoerber/laravel-one-time-operations)
This package lets you run one-time tasks in your Laravel application. Instead of creating a new migration for a small job, you can use this package to run the task just once. Any new one-time operations will be placed in the `database/operations` folder.

Also, adding this to your deployment can be really helpful because you won't need to manually run seeders if you want to modify data in your production environment.


### [barryvdh/laravel-debugbar](https://github.com/barryvdh/laravel-debugbar)
This package provides a developer toolbar for debugging Laravel applications. It includes a lot of helpful information like queries, routes, views, and more.

### [pestphp/pest](https://pestphp.com/docs/installation)
PESTPHP 3 is a testing framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.

#### Additional Plugins
- [pestphp/pest-plugin-faker](https://pestphp.com/docs/plugins#faker)
- [pestphp/pest-plugin-laravel](https://pestphp.com/docs/plugins#laravel)
- [pestphp/pest-plugin-livewire](https://pestphp.com/docs/plugins#livewire)

### [phpstan/phpstan](https://phpstan.org/user-guide/getting-started)
PHPStan scans your whole codebase and looks for both obvious & tricky bugs. Even in those rarely executed if statements that certainly aren't covered by tests.
- [timokoerber/laravel-one-time-operations](https://github.com/TimoKoerber/laravel-one-time-operations)
- [barryvdh/laravel-debugbar](https://github.com/barryvdh/laravel-debugbar)
- [phpstan/phpstan](https://phpstan.org/user-guide/getting-started)
- [pestphp/pest](https://pestphp.com/docs/installation)
- [pestphp/pest-plugin-faker](https://pestphp.com/docs/plugins#faker)
- [pestphp/pest-plugin-laravel](https://pestphp.com/docs/plugins#laravel)
- [pestphp/pest-plugin-livewire](https://pestphp.com/docs/plugins#livewire)

## Installation

Expand Down Expand Up @@ -118,8 +95,3 @@ larament my-cool-app

## Screenshots
![user-global-search](https://raw.githubusercontent.com/CodeWithDennis/larament/main/resources/images/user-global-search.jpg)

## Boilerplate
The following files are part of the "branding" and can be removed.
- resources/images/larament.png
- resources/images/user-global-search.jpg
14 changes: 8 additions & 6 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Filament\Tables\Columns\Column;
use Filament\Tables\Filters\BaseFilter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -19,11 +20,6 @@ public function register(): void
//
}

/*
* If you would like add different configurations to the components you can separate them into different methods.
* This way you can keep the code clean and organized.
*/

protected function translatableComponents(): void
{
foreach ([Field::class, BaseFilter::class, Placeholder::class, Column::class, Entry::class] as $component) {
Expand All @@ -35,10 +31,16 @@ protected function translatableComponents(): void
}
}

public function boot(): void
private function configureCommands(): void
{
DB::prohibitDestructiveCommands($this->app->isProduction());

Model::shouldBeStrict(! app()->isProduction());
}

public function boot(): void
{
$this->configureCommands();
$this->translatableComponents();
}
}

0 comments on commit 1a1a810

Please sign in to comment.