|
2 | 2 |
|
3 | 3 | ## Introduction
|
4 | 4 |
|
5 |
| -Our React starter kit provides a robust, modern starting point for building Laravel applications with a React frontend using [Inertia](https://inertiajs.com). |
| 5 | +This is a fork of the [Laravel + React Starter Kit](https://github.com/laravel/react-starter-kit) with my additional features and improvements. Such as: |
6 | 6 |
|
7 |
| -Inertia allows you to build modern, single-page React applications using classic server-side routing and controllers. This lets you enjoy the frontend power of React combined with the incredible backend productivity of Laravel and lightning-fast Vite compilation. |
| 7 | +- **Laravel Debugbar**: Integrated for debugging and profiling. |
| 8 | +- **Laravel Data & Typescript**: Utilizes [spatie/laravel-data](https://spatie.be/docs/laravel-data) for data handling and [spatie/typescript-transformer](https://spatie.be/docs/typescript-transformer/v2/laravel) for TypeScript support. |
| 9 | +- **Laravel Translatable & Translations**: Fully translated into Hebrew & supports translatable columns with [spatie/laravel-translatable](https://spatie.be/docs/laravel-translatable) |
| 10 | +- **MinIO & Media Library**: For file uploads and media management. |
| 11 | +- **Sail Included**: Docker support with Laravel Sail for easy local development. |
8 | 12 |
|
9 |
| -This React starter kit utilizes React 19, TypeScript, Tailwind, and the [shadcn/ui](https://ui.shadcn.com) and [radix-ui](https://www.radix-ui.com) component libraries. |
| 13 | +And much more! |
10 | 14 |
|
11 |
| -## Official Documentation |
| 15 | +## Requirements |
12 | 16 |
|
13 |
| -Documentation for all Laravel starter kits can be found on the [Laravel website](https://laravel.com/docs/starter-kits). |
| 17 | +From a Linux distro of your choice, you will need: |
14 | 18 |
|
15 |
| -## Contributing |
| 19 | +- [Docker](https://docs.docker.com/get-docker/) - Containerization platform. |
| 20 | +- [Docker Compose](https://docs.docker.com/compose/install/) - Tool for defining and running multi-container Docker applications. |
| 21 | +- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) - Version control system. |
| 22 | +- [Bun](https://bun.sh/docs/install) - JavaScript runtime. |
| 23 | +- [Node.js](https://nodejs.org/en/download/) - JavaScript runtime environment. |
| 24 | +- [PHP 8.4 or higher and Composer](https://laravel.com/docs/#installing-php) |
16 | 25 |
|
17 |
| -Thank you for considering contributing to our starter kit! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). |
| 26 | +## Installation |
18 | 27 |
|
19 |
| -## Code of Conduct |
| 28 | +1. Fork the repository and clone it to your local machine: |
20 | 29 |
|
21 |
| -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). |
| 30 | + This will help you get changes merged back into the main repository. |
22 | 31 |
|
23 |
| -## License |
| 32 | + ```bash |
| 33 | + git clone <your-fork-url> |
| 34 | + cd <your-repo-name> |
| 35 | + ``` |
24 | 36 |
|
25 |
| -The Laravel + React starter kit is open-sourced software licensed under the MIT license. |
| 37 | +2. Run app with Sail: |
| 38 | + |
| 39 | + ```bash |
| 40 | + # Don't forget to add the alias to your shell config file (e.g., .bashrc, .zshrc) |
| 41 | + # alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)' |
| 42 | + sail up -d |
| 43 | + ``` |
| 44 | + |
| 45 | +3. Install dependencies: |
| 46 | + |
| 47 | + ```bash |
| 48 | + sail composer install |
| 49 | + sail npm install # or `sail bun install` |
| 50 | + ``` |
| 51 | + |
| 52 | +4. Copy the `.env.example` file to `.env`: |
| 53 | + |
| 54 | + ```bash |
| 55 | + cp .env.example .env |
| 56 | + ``` |
| 57 | + |
| 58 | +5. Generate application key: |
| 59 | + |
| 60 | + ```bash |
| 61 | + sail artisan key:generate |
| 62 | + ``` |
| 63 | + |
| 64 | +6. Run migrations and seed the database: |
| 65 | + |
| 66 | + ```bash |
| 67 | + sail artisan migrate --seed |
| 68 | + ``` |
| 69 | + |
| 70 | +7. Run the development server: |
| 71 | + |
| 72 | + ```bash |
| 73 | + sail composer run dev |
| 74 | + ``` |
| 75 | + |
| 76 | +## Debugger & Playground |
| 77 | + |
| 78 | +The application includes the [Laravel Debugbar](https://laraveldebugbar.com/) for debugging and profiling. |
| 79 | + |
| 80 | +You can use the `Playground` at [http://localhost/playground](http://localhost/playground) and play with: |
| 81 | + |
| 82 | +- [The Controller](/app/Http/Controllers/PlaygroundController.php) - You can modify the controller to test different scenarios. |
| 83 | +- [The View](/resources/js/pages/playground/index.tsx) - You can modify the view to test different scenarios. |
| 84 | + |
| 85 | +## File Uploads w/ MinIO & Media Library |
| 86 | + |
| 87 | +MinIO is used for file uploads. You can access the MinIO dashboard at [localhost:9000](http://localhost:9000) with the credentials: |
| 88 | + |
| 89 | +- **Access Key**: sail |
| 90 | +- **Secret Key**: password |
| 91 | + |
| 92 | +In the laravel app you can use the package for managing files: [spatie/laravel-medialibrary](https://spatie.be/docs/laravel-medialibrary) |
| 93 | + |
| 94 | +### Temporary Files |
| 95 | + |
| 96 | +<!-- TODO: Implement --> |
| 97 | +... |
| 98 | + |
| 99 | +Note: `laravel-medialibrary` uses optimization packages. Install them with: |
| 100 | + |
| 101 | +```bash |
| 102 | +sudo apt install jpegoptim optipng pngquant gifsicle libavif-bin |
| 103 | +npm install -g svgo # or `sudo snap install svgo` |
| 104 | +``` |
| 105 | + |
| 106 | +## Translations & Translatable Columns |
| 107 | + |
| 108 | +The application is fully translated into Hebrew. The translation files are located in the `lang/he` directory and `lang/he.json` for JSON translations. |
| 109 | + |
| 110 | +Use the package [bottelet/translation-checker](https://bottelet.github.io/translation-checker) to check for missing translations, automatically generate translation with `Google Translate` using the command: |
| 111 | + |
| 112 | +```bash |
| 113 | +sail translations:check en --sort --translate-missing |
| 114 | +# └─target: `en`, `he` or any other language |
| 115 | +``` |
| 116 | + |
| 117 | +In addition, the `spatie/laravel-translatable` package is used to handle translatable columns in the database. You can define translatable attributes in your models like this: |
| 118 | + |
| 119 | +```php |
| 120 | +use Spatie\Translatable\HasTranslations; |
| 121 | +
|
| 122 | +class YourModel extends Model |
| 123 | +{ |
| 124 | + use HasTranslations; |
| 125 | +
|
| 126 | + public $translatable = ['name', 'description']; |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Laravel Data & Typescript |
| 131 | + |
| 132 | +The application uses [spatie/laravel-data](https://spatie.be/docs/laravel-data) for data handling and [spatie/typescript-transformer](https://spatie.be/docs/typescript-transformer/v2/laravel) for TypeScript support. |
| 133 | + |
| 134 | +Use `Laravel Data` to create DTOs with single source of truth for validation rules, type safety, and serialization. This allows you to define your data structures in a clean and maintainable way. |
| 135 | + |
| 136 | +Create a `Data` class with: |
| 137 | + |
| 138 | +```bash |
| 139 | +sail artisan make:data <DataClassName> |
| 140 | +``` |
| 141 | + |
| 142 | +Annotate your data classes with `TypeScript` to generate TypeScript types: |
| 143 | + |
| 144 | +```php |
| 145 | +use Spatie\LaravelData\Data; |
| 146 | +use Spatie\TypeScriptTransformer\Attributes\TypeScript; |
| 147 | +
|
| 148 | +#[TypeScript] |
| 149 | +class UserData extends Data |
| 150 | +{ |
| 151 | + public function __construct( |
| 152 | + public string $name, |
| 153 | + public string $email, |
| 154 | + // ... |
| 155 | + ) {} |
| 156 | +} |
| 157 | +
|
| 158 | +``` |
| 159 | + |
| 160 | +Then, generate the TypeScript types with: |
| 161 | + |
| 162 | +```bash |
| 163 | +sail artisan typescript:transform |
| 164 | +``` |
| 165 | + |
| 166 | +This will generate TypeScript types in the `resources/js/types/generated.d.ts` file so you can use them in your the frontend. |
| 167 | + |
| 168 | +You have Laravels's additional types such as `Paginator`, `EnumTtait` with usefull methods like `toCollection()` in `resources/js/types/index.d.ts`. |
| 169 | +
|
| 170 | +## Validation |
| 171 | +
|
| 172 | +In addition to the default validation rules, We have added the following custom validation rule: |
| 173 | +
|
| 174 | +- **Phone**: Validates that the input is a valid phone number using the package [propaganistas/laravel-phone](https://github.com/propaganistas/laravel-phone). |
0 commit comments