├── .editorconfig
├── .env.example
├── .gitattributes
├── .gitignore
├── .php-cs-fixer.php
├── .styleci.yml
├── README.md
├── app
├── Console
│ ├── Commands
│ │ ├── Treblle
│ │ │ └── MakeCommand.php
│ │ └── UserCreate.php
│ └── Kernel.php
├── Enums
│ └── Version.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Api
│ │ │ ├── Posts
│ │ │ │ ├── PostsDestroyController.php
│ │ │ │ ├── PostsIndexController.php
│ │ │ │ ├── PostsShowController.php
│ │ │ │ ├── PostsStoreController.php
│ │ │ │ └── PostsUpdateController.php
│ │ │ └── Users
│ │ │ │ ├── UsersDestroyController.php
│ │ │ │ ├── UsersIndexController.php
│ │ │ │ ├── UsersShowController.php
│ │ │ │ └── UsersUpdateController.php
│ │ └── AuthTokenController.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── Authenticate.php
│ │ ├── EncryptCookies.php
│ │ ├── PreventRequestsDuringMaintenance.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ ├── TrustHosts.php
│ │ ├── TrustProxies.php
│ │ └── VerifyCsrfToken.php
│ ├── Requests
│ │ └── Api
│ │ │ ├── AuthTokenRequest.php
│ │ │ └── v1_0
│ │ │ ├── PostStoreRequest.php
│ │ │ ├── PostUpdateRequest.php
│ │ │ └── UserUpdateRequest.php
│ └── Resources
│ │ └── v1_0
│ │ ├── PostResource.php
│ │ └── UserResource.php
├── Models
│ ├── Concerns
│ │ └── InteractsWithUuid.php
│ ├── Post.php
│ └── User.php
└── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── cors.php
├── database.php
├── filesystems.php
├── hashing.php
├── logging.php
├── mail.php
├── queue.php
├── sanctum.php
├── services.php
├── session.php
├── treblle.php
└── view.php
├── database
├── .gitignore
├── factories
│ ├── PostFactory.php
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2019_08_19_000000_create_failed_jobs_table.php
│ ├── 2019_12_14_000001_create_personal_access_tokens_table.php
│ └── 2022_02_16_143104_create_posts_table.php
└── seeders
│ └── DatabaseSeeder.php
├── infection.json
├── lang
├── en.json
└── en
│ ├── artisan.php
│ ├── auth.php
│ ├── pagination.php
│ ├── passwords.php
│ └── validation.php
├── package.json
├── phpstan.neon
├── phpunit.xml
├── public
├── .htaccess
├── favicon.ico
├── index.php
└── robots.txt
├── rector-bootstrap.php
├── rector.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── storage
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ ├── .gitignore
│ │ └── data
│ │ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── stubs
├── controller.destroy.stub
├── controller.index.stub
├── controller.show.stub
├── controller.store.stub
├── controller.update.stub
├── migration.create.stub
├── model.stub
├── pest.stub
├── request.stub
├── resource-collection.stub
└── resource.stub
├── tests
├── Analysis
│ └── AnalysisTest.php
├── CreatesApplication.php
├── Feature
│ ├── Console
│ │ └── Commands
│ │ │ └── UserCreateCommandTest.php
│ ├── Enums
│ │ └── VersionTest.php
│ ├── HomePageTest.php
│ ├── Http
│ │ └── Controllers
│ │ │ └── Api
│ │ │ ├── AuthTokenTest.php
│ │ │ └── v1_0
│ │ │ ├── Posts
│ │ │ ├── PostsDestroyControllerTest.php
│ │ │ ├── PostsIndexControllerTest.php
│ │ │ ├── PostsShowControllerTest.php
│ │ │ ├── PostsStoreControllerTest.php
│ │ │ └── PostsUpdateControllerTest.php
│ │ │ └── Users
│ │ │ ├── UsersDestroyControllerTest.php
│ │ │ ├── UsersIndexControllerTest.php
│ │ │ ├── UsersShowControllerTest.php
│ │ │ └── UsersUpdateControllerTest.php
│ └── Models
│ │ ├── PostTest.php
│ │ └── UserTest.php
├── Helpers.php
├── Pest.php
└── TestCase.php
└── webpack.mix.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{yml,yaml,vue}]
15 | indent_size = 2
16 |
17 | [docker-compose.yml]
18 | indent_size = 4
19 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_URL=http://localhost
6 |
7 | LOG_CHANNEL=stack
8 | LOG_DEPRECATIONS_CHANNEL=null
9 | LOG_LEVEL=debug
10 |
11 | DB_CONNECTION=mysql
12 | DB_HOST=127.0.0.1
13 | DB_PORT=3306
14 | DB_DATABASE=laravel_api_boilerplate
15 | DB_USERNAME=root
16 | DB_PASSWORD=
17 |
18 | BROADCAST_DRIVER=log
19 | CACHE_DRIVER=file
20 | FILESYSTEM_DISK=local
21 | QUEUE_CONNECTION=sync
22 | SESSION_DRIVER=file
23 | SESSION_LIFETIME=120
24 |
25 | MEMCACHED_HOST=127.0.0.1
26 |
27 | REDIS_HOST=127.0.0.1
28 | REDIS_PASSWORD=null
29 | REDIS_PORT=6379
30 |
31 | MAIL_MAILER=smtp
32 | MAIL_HOST=mailhog
33 | MAIL_PORT=1025
34 | MAIL_USERNAME=null
35 | MAIL_PASSWORD=null
36 | MAIL_ENCRYPTION=null
37 | MAIL_FROM_ADDRESS=null
38 | MAIL_FROM_NAME="${APP_NAME}"
39 |
40 | AWS_ACCESS_KEY_ID=
41 | AWS_SECRET_ACCESS_KEY=
42 | AWS_DEFAULT_REGION=us-east-1
43 | AWS_BUCKET=
44 | AWS_USE_PATH_STYLE_ENDPOINT=false
45 |
46 | PUSHER_APP_ID=
47 | PUSHER_APP_KEY=
48 | PUSHER_APP_SECRET=
49 | PUSHER_APP_CLUSTER=mt1
50 |
51 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
52 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
53 |
54 | TREBLLE_API_KEY=YOUR_API_KEY
55 | TREBLLE_PROJECT_ID=YOUR_PROJECT_ID
56 | #TREBLLE_IGNORED_ENV=local,dev,test
57 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
3 | *.blade.php diff=html
4 | *.css diff=css
5 | *.html diff=html
6 | *.md diff=markdown
7 | *.php diff=php
8 |
9 | /.github export-ignore
10 | CHANGELOG.md export-ignore
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Laravel ###
2 | /vendor/
3 | node_modules/
4 | npm-debug.log
5 | yarn-error.log
6 | storage/*.key
7 | Homestead.yaml
8 | Homestead.json
9 | /.vagrant
10 | .phpunit.result.cache
11 |
12 | # dotenv environment variable files
13 | .env
14 | .env.development.local
15 | .env.test.local
16 | .env.production.local
17 | .env.local
18 |
19 | ### Php Cs Fixer ###
20 | .php-cs-fixer.cache
21 |
22 | ### Coverage directory used by tools like phpunit and pest
23 | coverage.xml
24 | /.coverage
25 |
26 | ### Avoid to be pwned ###
27 | auth.json
28 |
29 | ### Laravel IDE Helper ###
30 | _ide_helper.php
31 | .phpstorm.meta.php
32 |
33 | ### Infection - Mutation Testing Suite ###
34 | infection.log
35 |
36 | ### Node ###
37 | # Logs
38 | logs
39 | *.log
40 | npm-debug.log*
41 | yarn-debug.log*
42 | yarn-error.log*
43 | lerna-debug.log*
44 | .pnpm-debug.log*
45 |
46 | # Diagnostic reports (https://nodejs.org/api/report.html)
47 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
48 |
49 | # Coverage directory used by tools like istanbul
50 | coverage
51 | *.lcov
52 |
53 | # TypeScript cache
54 | *.tsbuildinfo
55 |
56 | # Optional npm cache directory
57 | .npm
58 |
59 | # Optional eslint cache
60 | .eslintcache
61 |
62 | # Optional stylelint cache
63 | .stylelintcache
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # parcel-bundler cache (https://parceljs.org/)
72 | .cache
73 | .parcel-cache
74 |
75 | # Next.js build output
76 | .next
77 | out
78 |
79 | # Nuxt.js build / generate output
80 | .nuxt
81 | dist
82 |
83 | # Gatsby files
84 | .cache/
85 | # Comment in the public line in if your project uses Gatsby and not Next.js
86 | # https://nextjs.org/blog/next-9-1#public-directory-support
87 | # public
88 |
89 | # vuepress build output
90 | .vuepress/dist
91 |
92 | # vuepress v2.x temp and cache directory
93 | .temp
94 |
95 | # Serverless directories
96 | .serverless/
97 |
98 | # DynamoDB Local files
99 | .dynamodb/
100 |
101 | # Stores VSCode versions used for testing VSCode extensions
102 | .vscode
103 | .vscode-test
104 |
105 | # yarn v2
106 | .yarn/cache
107 | .yarn/unplugged
108 | .yarn/build-state.yml
109 | .yarn/install-state.gz
110 | .pnp.*
111 |
112 | ### Node Patch ###
113 | # Serverless Webpack directories
114 | .webpack/
115 |
116 | # SvelteKit build / generate output
117 | .svelte-kit
118 |
119 | ### PhpStorm ###
120 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
121 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
122 |
123 | # User-specific stuff
124 | .idea/**/workspace.xml
125 | .idea/**/tasks.xml
126 | .idea/**/usage.statistics.xml
127 | .idea/**/dictionaries
128 | .idea/**/shelf
129 |
130 | # AWS User-specific
131 | .idea/**/aws.xml
132 |
133 | # Generated files
134 | .idea/**/contentModel.xml
135 |
136 | # Sensitive or high-churn files
137 | .idea/**/dataSources/
138 | .idea/**/dataSources.ids
139 | .idea/**/dataSources.local.xml
140 | .idea/**/sqlDataSources.xml
141 | .idea/**/dynamic.xml
142 | .idea/**/uiDesigner.xml
143 | .idea/**/dbnavigator.xml
144 |
145 | # Gradle
146 | .idea/**/gradle.xml
147 | .idea/**/libraries
148 |
149 | # Gradle and Maven with auto-import
150 | # When using Gradle or Maven with auto-import, you should exclude module files,
151 | # since they will be recreated, and may cause churn. Uncomment if using
152 | # auto-import.
153 | # .idea/artifacts
154 | # .idea/compiler.xml
155 | # .idea/jarRepositories.xml
156 | # .idea/modules.xml
157 | # .idea/*.iml
158 | # .idea/modules
159 | # *.iml
160 | # *.ipr
161 |
162 | # CMake
163 | cmake-build-*/
164 |
165 | # Mongo Explorer plugin
166 | .idea/**/mongoSettings.xml
167 |
168 | # File-based project format
169 | *.iws
170 |
171 | # mpeltonen/sbt-idea plugin
172 | .idea_modules/
173 |
174 | # JIRA plugin
175 | atlassian-ide-plugin.xml
176 |
177 | # Cursive Clojure plugin
178 | .idea/replstate.xml
179 |
180 | # SonarLint plugin
181 | .idea/sonarlint/
182 |
183 | # Editor-based Rest Client
184 | .idea/httpRequests
185 |
186 | ### PhpStorm Patch ###
187 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
188 |
189 | # *.iml
190 | # modules.xml
191 | # .idea/misc.xml
192 | # *.ipr
193 |
194 | # Sonarlint plugin
195 | # https://plugins.jetbrains.com/plugin/7973-sonarlint
196 | .idea/**/sonarlint/
197 |
198 | # SonarQube Plugin
199 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
200 | .idea/**/sonarIssues.xml
201 |
202 | # Markdown Navigator plugin
203 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
204 | .idea/**/markdown-navigator.xml
205 | .idea/**/markdown-navigator-enh.xml
206 | .idea/**/markdown-navigator/
207 |
208 | # Cache file creation bug
209 | # See https://youtrack.jetbrains.com/issue/JBR-2257
210 | .idea/$CACHE_FILE$
211 |
212 | # CodeStream plugin
213 | # https://plugins.jetbrains.com/plugin/12206-codestream
214 | .idea/codestream.xml
215 |
--------------------------------------------------------------------------------
/.php-cs-fixer.php:
--------------------------------------------------------------------------------
1 | ['syntax' => 'short'],
10 | 'binary_operator_spaces' => [
11 | 'default' => 'single_space',
12 | 'operators' => [
13 | '=' => 'align_single_space_minimal',
14 | '=>' => 'align_single_space_minimal',
15 | '|' => 'no_space'
16 | ],
17 | ],
18 | 'blank_line_after_namespace' => true,
19 | 'blank_line_after_opening_tag' => true,
20 | 'blank_line_before_statement' => [
21 | 'statements' => [
22 | 'break',
23 | 'continue',
24 | 'declare',
25 | 'return',
26 | 'throw',
27 | 'try',
28 | ],
29 | ],
30 | 'braces' => true,
31 | 'cast_spaces' => true,
32 | 'class_attributes_separation' => [
33 | 'elements' => [
34 | 'const' => 'one',
35 | 'method' => 'one',
36 | 'property' => 'one',
37 | ],
38 | ],
39 | 'class_definition' => true,
40 | 'concat_space' => ['spacing' => 'none'],
41 | 'constant_case' => ['case' => 'lower'],
42 | 'declare_equal_normalize' => true,
43 | 'declare_strict_types' => true,
44 | 'echo_tag_syntax' => ['format' => 'long'],
45 | 'elseif' => true,
46 | 'encoding' => true,
47 | 'final_internal_class' => true,
48 | 'full_opening_tag' => true,
49 | 'fully_qualified_strict_types' => true,
50 | 'function_declaration' => true,
51 | 'function_typehint_space' => true,
52 | 'heredoc_to_nowdoc' => true,
53 | 'include' => true,
54 | 'increment_style' => ['style' => 'post'],
55 | 'indentation_type' => true,
56 | 'linebreak_after_opening_tag' => true,
57 | 'line_ending' => true,
58 | 'lowercase_cast' => true,
59 | 'lowercase_keywords' => true,
60 | 'lowercase_static_reference' => true,
61 | 'magic_method_casing' => true,
62 | 'magic_constant_casing' => true,
63 | 'method_argument_space' => true,
64 | 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
65 | 'native_function_casing' => true,
66 | 'new_with_braces' => true,
67 | 'no_alias_functions' => true,
68 | 'no_blank_lines_after_class_opening' => true,
69 | 'no_blank_lines_after_phpdoc' => true,
70 | 'no_closing_tag' => true,
71 | 'no_empty_phpdoc' => true,
72 | 'no_empty_statement' => true,
73 | 'no_extra_blank_lines' => [
74 | 'tokens' => [
75 | 'extra',
76 | 'throw',
77 | 'use',
78 | 'use_trait',
79 | ],
80 | ],
81 | 'no_leading_import_slash' => true,
82 | 'no_leading_namespace_whitespace' => true,
83 | 'no_mixed_echo_print' => ['use' => 'echo'],
84 | 'no_multiline_whitespace_around_double_arrow' => true,
85 | 'no_short_bool_cast' => true,
86 | 'no_singleline_whitespace_before_semicolons' => true,
87 | 'no_spaces_after_function_name' => true,
88 | 'no_spaces_around_offset' => [
89 | 'positions' => ['inside'],
90 | ],
91 | 'no_spaces_inside_parenthesis' => true,
92 | 'no_trailing_comma_in_list_call' => true,
93 | 'no_trailing_comma_in_singleline_array' => true,
94 | 'no_trailing_whitespace' => true,
95 | 'no_trailing_whitespace_in_comment' => true,
96 | 'no_unneeded_control_parentheses' => [
97 | 'statements' => [
98 | 'break',
99 | 'clone',
100 | 'continue',
101 | 'echo_print',
102 | 'return',
103 | 'switch_case',
104 | 'yield',
105 | ],
106 | ],
107 | 'no_unreachable_default_argument_value' => true,
108 | 'no_unused_imports' => true,
109 | 'no_useless_else' => true,
110 | 'no_useless_return' => true,
111 | 'no_whitespace_before_comma_in_array' => true,
112 | 'no_whitespace_in_blank_line' => true,
113 | 'normalize_index_brace' => true,
114 | 'not_operator_with_successor_space' => true,
115 | 'object_operator_without_whitespace' => true,
116 | 'ordered_imports' => ['sort_algorithm' => 'alpha'],
117 | 'php_unit_strict' => true,
118 | 'php_unit_test_class_requires_covers' => true,
119 | 'phpdoc_add_missing_param_annotation' => true,
120 | 'phpdoc_align' => false,
121 | 'phpdoc_indent' => true,
122 | 'phpdoc_inline_tag_normalizer' => true,
123 | 'phpdoc_no_access' => true,
124 | 'phpdoc_no_package' => true,
125 | 'phpdoc_no_useless_inheritdoc' => true,
126 | 'phpdoc_order' => true,
127 | 'phpdoc_scalar' => true,
128 | 'phpdoc_single_line_var_spacing' => true,
129 | 'phpdoc_summary' => true,
130 | 'phpdoc_to_comment' => true,
131 | 'phpdoc_trim' => true,
132 | 'phpdoc_types' => true,
133 | 'phpdoc_var_without_name' => true,
134 | 'psr_autoloading' => true,
135 | 'self_accessor' => true,
136 | 'semicolon_after_instruction' => true,
137 | 'short_scalar_cast' => true,
138 | 'simplified_null_return' => true,
139 | 'single_blank_line_at_eof' => true,
140 | 'single_blank_line_before_namespace' => true,
141 | 'single_class_element_per_statement' => [
142 | 'elements' => [
143 | 'const',
144 | 'property',
145 | ],
146 | ],
147 | 'single_import_per_statement' => true,
148 | 'single_line_after_imports' => true,
149 | 'single_line_comment_style' => [
150 | 'comment_types' => ['hash'],
151 | ],
152 | 'single_quote' => true,
153 | 'single_trait_insert_per_statement' => true,
154 | 'space_after_semicolon' => true,
155 | 'standardize_not_equals' => true,
156 | 'strict_comparison' => true,
157 | 'strict_param' => true,
158 | 'switch_case_semicolon_to_colon' => true,
159 | 'switch_case_space' => true,
160 | 'ternary_operator_spaces' => true,
161 | 'trailing_comma_in_multiline' => [
162 | 'elements' => ['arrays'],
163 | ],
164 | 'trim_array_spaces' => true,
165 | 'unary_operator_spaces' => true,
166 | 'visibility_required' => [
167 | 'elements' => [
168 | 'property',
169 | 'method',
170 | 'const',
171 | ],
172 | ],
173 | 'whitespace_after_comma_in_array' => true,
174 | ];
175 |
176 | $finder = PhpCsFixer\Finder::create()
177 | ->notPath('bootstrap')
178 | ->notPath('storage')
179 | ->notPath('vendor')
180 | ->in(getcwd())
181 | ->name('*.php')
182 | ->notName('*.blade.php')
183 | ->notName('index.php')
184 | ->notName('server.php')
185 | ->ignoreDotFiles(true)
186 | ->ignoreVCS(true);
187 |
188 | $config = new PhpCsFixer\Config();
189 | return $config
190 | ->setFinder($finder)
191 | ->setRules($rules)
192 | ->setRiskyAllowed(true)
193 | ->setCacheFile(__DIR__.'/.php-cs-fixer.cache')
194 | ->setUsingCache(true);
195 |
--------------------------------------------------------------------------------
/.styleci.yml:
--------------------------------------------------------------------------------
1 | php:
2 | preset: laravel
3 | version: 8
4 | disabled:
5 | - no_unused_imports
6 | finder:
7 | not-name:
8 | - index.php
9 | js:
10 | finder:
11 | not-name:
12 | - webpack.mix.js
13 | css: true
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Laravel API boilerplate 🚀
4 |
5 | An awesome boilerplate for your next Laravel 9 based API. It's only goal is to simply **kick-start your API development** and provide you with some of the best practices when building amazing and scalable REST APIs 🔥
6 |
7 | ## Features 🍭
8 |
9 | ### REST API Best Practices
10 | We baked in all the best REST API practices in terms of structuring your API, naming conversations, HTTP methods, responses and optimizations
11 |
12 | ### Concrete examples
13 | We all like to learn by examples and that's why the boilerplate comes with a concrete example that include everything from folder structure, routes to naming controllers
14 |
15 | ### Scaffolding Artisan command
16 | Tired of manually creating controllers, resources, test and form requests each time for new API endpoints. We were too. That's why we added a command that does all of that for you. Just run `php artisan treblle:make` and you get everything you need in a second
17 |
18 | ### Built-in versioning
19 | Building a versioning system that scales is always hard and that's why we built in a robust versioning system that is easy to use and can grow with the project
20 |
21 | ### Single responsibility controllers
22 | The boilerplate uses single responsibility controllers that make it painfully obvious what's going on and can be used with different versions
23 |
24 | ### Models, migrations and factories
25 | We built two tables Users and Posts and defined everything you might need on a database and model level
26 |
27 | ### Sanctum authentication
28 | Built in Laravel Sanctum authentication included in the boilerplate.
29 |
30 | ### Magical UUID trait
31 | Want to use UUIDs but find it to much work just use our built in `InteractsWithUuid` trait and have fun with UUIDs
32 |
33 | ### Spawn a new user quickly
34 | Easily create a new user without messing around with database clients or CRUD systems by using our custom command `php artisan user:create`
35 |
36 | ### Treblle built-in
37 | We added an awesome Laravel package called Treblle. Out of the box Treblle gives you: real-time API monitoring, automatically generated and updated documentation, error tracking and logging, API analytics, quality scoring and much more. To get started with Treblle just run `php artisan treblle:start` and follow the instructions or visit [treblle.com](https://treblle.com) for more information
38 |
39 |
40 | ## Requirements
41 | * PHP 8.1+
42 | * Laravel 9+
43 |
44 | ## Dependencies
45 |
46 | - [composer/semver](https://github.com/composer/semver)
47 | - [guzzlehttp/guzzle](https://github.com/guzzle/guzzle)
48 | - [laravel/framework](https://github.com/laravel/framework)
49 | - [laravel/sanctum](https://github.com/laravel/sanctum)
50 | - [treblle/treblle-laravel](https://github.com/treblle/treblle-laravel)
51 |
52 | ## Getting started
53 |
54 | Press the `Use this template` button at the top of this repository to create a new API with this boilerplate and 🎉.
55 |
56 | ## Thank you
57 |
58 | The boilerplate was built by [Maurizio](https://github.com/leMaur), with some help from [cindreta](https://github.com/cindreta) and sponsored by [Treblle](https://treblle.com). We would love to have you as our contributor so please feel free to make pull requests and help us make the best API boilerplate on Github 💪🏻
59 |
60 | ## The 10 REST Commandments E-book
61 |
62 | Grab a free copy of The 10 REST Commandments e-book and learn how to build great REST APIs that scale in any language 👉 [https://treblle.com/ebooks/the-10-rest-commandments](https://treblle.com/ebooks/the-10-rest-commandments)
63 |
64 |
65 | ## Support
66 |
67 | If you have problems of any kind feel free to reach out via or email vedran@treblle.com, and we'll
68 | do our best to help you out.
69 |
70 | ## License
71 |
72 | Copyright 2022, Treblle Limited. Licensed under the MIT license:
73 | http://www.opensource.org/licenses/mit-license.php
74 |
--------------------------------------------------------------------------------
/app/Console/Commands/Treblle/MakeCommand.php:
--------------------------------------------------------------------------------
1 | argument('name');
41 |
42 | /** @var string $version */
43 | $version = $this->option('ver');
44 |
45 | $resource = (string) Str::of($name)->studly()->plural();
46 | $version = Version::from($version)->name;
47 |
48 | if ((bool) $this->option('controllers')) {
49 | $this->makeControllers($resource, $version);
50 |
51 | return 0;
52 | }
53 |
54 | if ((bool) $this->option('request')) {
55 | $this->makeRequests($resource, $version);
56 |
57 | return 0;
58 | }
59 |
60 | if ((bool) $this->option('resource')) {
61 | $this->makeResources($resource, $version);
62 |
63 | return 0;
64 | }
65 |
66 | if (! (bool) $this->option('no-controllers')) {
67 | $this->makeControllers($resource, $version);
68 | }
69 |
70 | if (! (bool) $this->option('no-request')) {
71 | $this->makeRequests($resource, $version);
72 | }
73 |
74 | if (! (bool) $this->option('no-resource')) {
75 | $this->makeResources($resource, $version);
76 | }
77 |
78 | $this->makeTests($resource, $version);
79 |
80 | return 0;
81 | }
82 |
83 | private function makeControllers(string $resource, string $version): void
84 | {
85 | collect(['Destroy', 'Index', 'Show', 'Store', 'Update'])
86 | ->each(fn (string $action): int => $this->callSilently('make:controller', [
87 | 'name' => $this->buildFilePath('controller', $resource, $version, $action),
88 | '--type' => Str::lower($action),
89 | '--model' => $this->guessModelFromResourceName($resource),
90 | ]));
91 | }
92 |
93 | private function makeRequests(string $resource, string $version): void
94 | {
95 | collect(['Store', 'Update'])
96 | ->each(fn (string $action): int => $this->callSilently('make:request', [
97 | 'name' => $this->buildFilePath('request', $resource, $version, $action),
98 | ]));
99 | }
100 |
101 | private function makeResources(string $resource, string $version): void
102 | {
103 | $this->callSilently('make:resource', [
104 | 'name' => $this->buildFilePath('resource', $resource, $version),
105 | ]);
106 | }
107 |
108 | private function makeTests(string $resource, string $version): void
109 | {
110 | collect(['Destroy', 'Index', 'Show', 'Store', 'Update'])
111 | ->each(fn (string $action): int => $this->callSilently('make:test', [
112 | 'name' => $this->buildFilePath('test', $resource, $version, $action),
113 | '--pest' => 1,
114 | ]));
115 | }
116 |
117 | private function buildFilePath(string $type, string $resource, string $version, string $action = null): string
118 | {
119 | return match ($type) {
120 | 'controller' => sprintf('Api/%s/%s%sController', $resource, $resource, $action),
121 | 'request' => sprintf('Api/%s/%s%sRequest', $version, Str::singular($resource), $action),
122 | 'resource' => sprintf('%s/%sResource', $version, Str::singular($resource)),
123 | default => sprintf('Http/Controllers/Api/%s/%s/%s%sControllerTest', $version, $resource, $resource, $action),
124 | };
125 | }
126 |
127 | private function guessModelFromResourceName(string $resource): ?string
128 | {
129 | /** @var class-string $model */
130 | $model = 'App\\Models\\'.Str::of($resource)->studly()->singular();
131 |
132 | try {
133 | $reflector = new ReflectionClass($model);
134 | $filename = $reflector->getFileName();
135 | } catch (ReflectionException) {
136 | return null;
137 | }
138 |
139 | if ($filename === false) {
140 | return null;
141 | }
142 |
143 | if (! file_exists($filename)) {
144 | return null;
145 | }
146 |
147 | return $model;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/app/Console/Commands/UserCreate.php:
--------------------------------------------------------------------------------
1 | hasNoOptions()) {
27 | $this->info(trans('artisan.create_user.description'));
28 |
29 | if (! $this->confirm(trans('artisan.create_user.dialogs.confirm_before_executing'), true)) {
30 | return 1;
31 | }
32 | }
33 |
34 | $validator = Validator::make($this->inputData(), $this->rules());
35 |
36 | if ($validator->fails()) {
37 | foreach ($validator->errors()->all() as $message) {
38 | $this->error($message);
39 | }
40 |
41 | return 1;
42 | }
43 |
44 | $data = $validator->validated();
45 | User::create(array_merge($data, [
46 | 'password' => Hash::make($data['password']),
47 | ]));
48 |
49 | $this->info(trans('artisan.create_user.alerts.confirmation'));
50 | $this->newLine();
51 | $this->table(['Name', 'Email', 'Password'], [$data]);
52 |
53 | return 0;
54 | }
55 |
56 | private function inputData(): array
57 | {
58 | return [
59 | 'name' => $this->option('name') ?? $this->ask(trans('artisan.create_user.questions.name')),
60 | 'email' => $this->option('email') ?? $this->ask(trans('artisan.create_user.questions.email')),
61 | 'password' => $this->option('password') ?? $this->ask(trans('artisan.create_user.questions.password')),
62 | ];
63 | }
64 |
65 | private function rules(): array
66 | {
67 | return [
68 | 'name' => ['required', 'string', 'max:255'],
69 | 'email' => ['required', 'string', 'email', 'max:255'],
70 | 'password' => ['required', 'string', 'min:6'],
71 | ];
72 | }
73 |
74 | private function hasNoOptions(): bool
75 | {
76 | return collect([
77 | Arr::get($this->options(), 'name'),
78 | Arr::get($this->options(), 'email'),
79 | Arr::get($this->options(), 'password'),
80 | ])->filter()->count() === 0;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')->hourly();
20 | }
21 |
22 | /**
23 | * Register the commands for the application.
24 | *
25 | * @return void
26 | */
27 | protected function commands()
28 | {
29 | $this->load(__DIR__.'/Commands');
30 |
31 | require base_path('routes/console.php');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Enums/Version.php:
--------------------------------------------------------------------------------
1 | value, $constraints);
20 | }
21 |
22 | public function equalsTo(self $version): bool
23 | {
24 | return Comparator::equalTo(
25 | self::normalize($this->value),
26 | self::normalize($version->value)
27 | );
28 | }
29 |
30 | public function notEqualsTo(self $version): bool
31 | {
32 | return Comparator::notEqualTo(
33 | self::normalize($this->value),
34 | self::normalize($version->value)
35 | );
36 | }
37 |
38 | public function greaterThan(self $version): bool
39 | {
40 | return Comparator::greaterThan(
41 | self::normalize($this->value),
42 | self::normalize($version->value)
43 | );
44 | }
45 |
46 | public function greaterThanOrEqualsTo(self $version): bool
47 | {
48 | return Comparator::greaterThanOrEqualTo(
49 | self::normalize($this->value),
50 | self::normalize($version->value)
51 | );
52 | }
53 |
54 | public function lessThan(self $version): bool
55 | {
56 | return Comparator::lessThan(
57 | self::normalize($this->value),
58 | self::normalize($version->value)
59 | );
60 | }
61 |
62 | public function lessThanOrEqualsTo(self $version): bool
63 | {
64 | return Comparator::lessThanOrEqualTo(
65 | self::normalize($this->value),
66 | self::normalize($version->value)
67 | );
68 | }
69 |
70 | private static function normalize(string $input): string
71 | {
72 | return (string) Str::of($input)->ltrim('v');
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | >
16 | */
17 | protected $dontReport = [
18 | //
19 | ];
20 |
21 | /**
22 | * A list of the inputs that are never flashed for validation exceptions.
23 | *
24 | * @var array
25 | */
26 | protected $dontFlash = [
27 | 'current_password',
28 | 'password',
29 | 'password_confirmation',
30 | ];
31 |
32 | /**
33 | * Register the exception handling callbacks for the application.
34 | *
35 | * @return void
36 | */
37 | public function register()
38 | {
39 | $this->reportable(function (Throwable $e) {
40 | //
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Posts/PostsDestroyController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
19 | Response::HTTP_NOT_FOUND
20 | );
21 |
22 | $post->delete();
23 |
24 | return response()->json([], Response::HTTP_NO_CONTENT);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Posts/PostsIndexController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
21 | Response::HTTP_NOT_FOUND
22 | );
23 |
24 | $posts = Post::query()->paginate();
25 |
26 | return PostResource::collection($posts);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Posts/PostsShowController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
21 | Response::HTTP_NOT_FOUND
22 | );
23 |
24 | return PostResource::make($post);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Posts/PostsStoreController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
20 | Response::HTTP_NOT_FOUND
21 | );
22 |
23 | $post = $request->user()->posts()->create($request->validated());
24 |
25 | return PostResource::make($post);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Posts/PostsUpdateController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
21 | Response::HTTP_NOT_FOUND
22 | );
23 |
24 | $post->update($request->validated());
25 |
26 | return PostResource::make($post->refresh());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Users/UsersDestroyController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
19 | Response::HTTP_NOT_FOUND
20 | );
21 |
22 | $user->delete();
23 |
24 | return response()->json([], Response::HTTP_NO_CONTENT);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Users/UsersIndexController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
21 | Response::HTTP_NOT_FOUND
22 | );
23 |
24 | $users = User::query()->paginate();
25 |
26 | return UserResource::collection($users);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Users/UsersShowController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
21 | Response::HTTP_NOT_FOUND
22 | );
23 |
24 | return UserResource::make($user);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/Users/UsersUpdateController.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
21 | Response::HTTP_NOT_FOUND
22 | );
23 |
24 | $user->update($request->validated());
25 |
26 | return UserResource::make($user->refresh());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Controllers/AuthTokenController.php:
--------------------------------------------------------------------------------
1 | validated();
20 |
21 | /** @var User $user */
22 | $user = User::whereEmail($data['email'])->first();
23 |
24 | if (! Hash::check($data['password'], $user->password)) {
25 | throw ValidationException::withMessages([
26 | 'email' => [(string) trans('validation.credentials')],
27 | ]);
28 | }
29 |
30 | return response()->json([
31 | 'token' => $user
32 | ->createToken($data['token_name'])
33 | ->plainTextToken,
34 | ], Response::HTTP_CREATED);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 |
38 | */
39 | protected $middleware = [
40 | // \App\Http\Middleware\TrustHosts::class,
41 | TrustProxies::class,
42 | HandleCors::class,
43 | PreventRequestsDuringMaintenance::class,
44 | ValidatePostSize::class,
45 | TrimStrings::class,
46 | ConvertEmptyStringsToNull::class,
47 | ];
48 |
49 | /**
50 | * The application's route middleware groups.
51 | *
52 | * @var array>
53 | */
54 | protected $middlewareGroups = [
55 | 'web' => [
56 | EncryptCookies::class,
57 | AddQueuedCookiesToResponse::class,
58 | StartSession::class,
59 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
60 | ShareErrorsFromSession::class,
61 | VerifyCsrfToken::class,
62 | SubstituteBindings::class,
63 | ],
64 |
65 | 'api' => [
66 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
67 | 'throttle:api',
68 | SubstituteBindings::class,
69 | ],
70 | ];
71 |
72 | /**
73 | * The application's route middleware.
74 | *
75 | * These middleware may be assigned to groups or used individually.
76 | *
77 | * @var array
78 | */
79 | protected $routeMiddleware = [
80 | 'auth' => Authenticate::class,
81 | 'auth.basic' => AuthenticateWithBasicAuth::class,
82 | 'cache.headers' => SetCacheHeaders::class,
83 | 'can' => Authorize::class,
84 | 'guest' => RedirectIfAuthenticated::class,
85 | 'password.confirm' => RequirePassword::class,
86 | 'signed' => ValidateSignature::class,
87 | 'throttle' => ThrottleRequests::class,
88 | 'verified' => EnsureEmailIsVerified::class,
89 | ];
90 | }
91 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
20 | return route('login');
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | protected $except = [
17 | //
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/app/Http/Middleware/PreventRequestsDuringMaintenance.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | protected $except = [
17 | //
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/app/Http/Middleware/RedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | check()) {
28 | return redirect(RouteServiceProvider::HOME);
29 | }
30 | }
31 |
32 | return $next($request);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | protected $except = [
17 | 'current_password',
18 | 'password',
19 | 'password_confirmation',
20 | ];
21 | }
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustHosts.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | public function hosts()
17 | {
18 | return [
19 | $this->allSubdomainsOfApplicationUrl(),
20 | ];
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustProxies.php:
--------------------------------------------------------------------------------
1 | |string|null
16 | */
17 | protected $proxies;
18 |
19 | /**
20 | * The headers that should be used to detect proxies.
21 | *
22 | * @var int
23 | */
24 | protected $headers = Request::HEADER_X_FORWARDED_FOR|
25 | Request::HEADER_X_FORWARDED_HOST|
26 | Request::HEADER_X_FORWARDED_PORT|
27 | Request::HEADER_X_FORWARDED_PROTO|
28 | Request::HEADER_X_FORWARDED_AWS_ELB;
29 | }
30 |
--------------------------------------------------------------------------------
/app/Http/Middleware/VerifyCsrfToken.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | protected $except = [
17 | //
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/app/Http/Requests/Api/AuthTokenRequest.php:
--------------------------------------------------------------------------------
1 | ['required', 'email', 'exists:users'],
20 | 'password' => ['required'],
21 | 'token_name' => ['required', 'alpha_num', 'max:50'],
22 | ];
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Requests/Api/v1_0/PostStoreRequest.php:
--------------------------------------------------------------------------------
1 | ['required', 'string', Rule::unique('posts'), 'max:255'],
21 | 'content' => ['required', 'string'],
22 | ];
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Requests/Api/v1_0/PostUpdateRequest.php:
--------------------------------------------------------------------------------
1 | ['required', 'string', Rule::unique('posts')->ignore($this->id), 'max:255'],
25 | 'content' => ['required', 'string'],
26 | ];
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Requests/Api/v1_0/UserUpdateRequest.php:
--------------------------------------------------------------------------------
1 | ['required', 'string', 'max:255'],
25 | 'email' => ['required', Rule::unique('users')->ignore($this->id), 'email', 'max:255'],
26 | ];
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Resources/v1_0/PostResource.php:
--------------------------------------------------------------------------------
1 | $this->uuid,
26 | 'title' => $this->title,
27 | 'body' => $this->content,
28 | 'created_at' => $this->created_at,
29 | 'updated_at' => $this->updated_at,
30 | 'author' => $this->whenLoaded('author', UserResource::make($this->author)),
31 | ];
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Http/Resources/v1_0/UserResource.php:
--------------------------------------------------------------------------------
1 | $this->uuid,
26 | 'name' => $this->name,
27 | 'email' => $this->email, // email address is considered a sensitive data, we advise you to avoid exposing it on public!
28 | 'created_at' => $this->created_at,
29 | 'updated_at' => $this->updated_at,
30 | ];
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Models/Concerns/InteractsWithUuid.php:
--------------------------------------------------------------------------------
1 | uuid = Str::uuid();
18 | });
19 | }
20 |
21 | public function getRouteKeyName(): string
22 | {
23 | return 'uuid';
24 | }
25 |
26 | /**
27 | * @param Builder $query
28 | */
29 | public function scopeFindByUuid(Builder $query, string $uuid): Model|null
30 | {
31 | return $query->where('uuid', $uuid)->first();
32 | }
33 |
34 | /**
35 | * @param Builder $query
36 | * @throws ModelNotFoundException
37 | */
38 | public function scopeFindOrFailByUuid(Builder $query, string $uuid): Model
39 | {
40 | return $query->where('uuid', $uuid)->firstOrFail();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Models/Post.php:
--------------------------------------------------------------------------------
1 |
50 | */
51 | public function author(): BelongsTo
52 | {
53 | return $this->belongsTo(User::class, 'user_id');
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/Models/User.php:
--------------------------------------------------------------------------------
1 |
67 | */
68 | protected $fillable = [
69 | 'name',
70 | 'email',
71 | 'password',
72 | ];
73 |
74 | /**
75 | * The attributes that should be hidden for serialization.
76 | *
77 | * @var array
78 | */
79 | protected $hidden = [
80 | 'password',
81 | 'remember_token',
82 | ];
83 |
84 | /**
85 | * The attributes that should be cast.
86 | *
87 | * @var array
88 | */
89 | protected $casts = [
90 | 'email_verified_at' => 'datetime',
91 | ];
92 |
93 | /**
94 | * @return HasMany
95 | */
96 | public function posts(): HasMany
97 | {
98 | return $this->hasMany(Post::class);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | protected $policies = [
17 | // 'App\Models\Model' => 'App\Policies\ModelPolicy',
18 | ];
19 |
20 | /**
21 | * Register any authentication / authorization services.
22 | *
23 | * @return void
24 | */
25 | public function boot()
26 | {
27 | $this->registerPolicies();
28 |
29 | //
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | >
18 | */
19 | protected $listen = [
20 | Registered::class => [
21 | SendEmailVerificationNotification::class,
22 | ],
23 | ];
24 |
25 | /**
26 | * Register any events for your application.
27 | *
28 | * @return void
29 | */
30 | public function boot()
31 | {
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | configureRateLimiting();
31 |
32 | $this->routes(function () {
33 | Route::prefix('api/{version}')
34 | ->middleware('api')
35 | ->group(base_path('routes/api.php'));
36 |
37 | Route::prefix('api')
38 | ->middleware(['api', 'treblle'])
39 | ->post('auth/token', AuthTokenController::class)
40 | ->name('api.auth.token');
41 |
42 | Route::middleware('web')
43 | ->group(base_path('routes/web.php'));
44 | });
45 | }
46 |
47 | /**
48 | * Configure the rate limiters for the application.
49 | */
50 | private function configureRateLimiting(): void
51 | {
52 | RateLimiter::for('api', fn (Request $request) => Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "treblle/laravel-api-boilerplate",
3 | "type": "project",
4 | "description": "Kick-start you next Laravel based API with this awesome boilerplate",
5 | "keywords": ["api", "boilerplate", "template", "laravel"],
6 | "license": "MIT",
7 | "require": {
8 | "php": "^8.1",
9 | "composer/semver": "^3.2",
10 | "fruitcake/laravel-cors": "^2.0.5",
11 | "guzzlehttp/guzzle": "^7.2",
12 | "laravel/framework": "^9.0",
13 | "laravel/sanctum": "^2.14",
14 | "laravel/tinker": "^2.7",
15 | "treblle/treblle-laravel": "^2.6"
16 | },
17 | "require-dev": {
18 | "fakerphp/faker": "^1.9.1",
19 | "laravel/sail": "^1.0.1",
20 | "lemaur/toolbox": "^3.0",
21 | "mockery/mockery": "^1.4.4",
22 | "nunomaduro/collision": "^6.1",
23 | "phpunit/phpunit": "^9.5.10",
24 | "spatie/laravel-ignition": "^1.0"
25 | },
26 | "autoload": {
27 | "psr-4": {
28 | "App\\": "app/",
29 | "Database\\Factories\\": "database/factories/",
30 | "Database\\Seeders\\": "database/seeders/"
31 | }
32 | },
33 | "autoload-dev": {
34 | "psr-4": {
35 | "Tests\\": "tests/"
36 | }
37 | },
38 | "scripts": {
39 | "post-autoload-dump": [
40 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
41 | "@php artisan package:discover --ansi"
42 | ],
43 | "post-update-cmd": [
44 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force",
45 | "@php artisan ide-helper:generate",
46 | "@php artisan ide-helper:meta"
47 | ],
48 | "post-root-package-install": "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
49 | "post-create-project-cmd": "@php artisan key:generate --ansi",
50 | "models": "@php artisan ide-helper:models --write",
51 | "analyse": "./vendor/bin/phpstan analyse --memory-limit=2G",
52 | "refactor": "./vendor/bin/rector process",
53 | "format": "./vendor/bin/php-cs-fixer fix --allow-risky=yes",
54 | "test": "./vendor/bin/pest",
55 | "test:fast": "./vendor/bin/pest --parallel",
56 | "test:coverage": "./vendor/bin/pest --coverage --min=100 --coverage-html=.coverage --coverage-clover=coverage.xml",
57 | "test:mutation": "XDEBUG_MODE=coverage ./vendor/bin/infection --test-framework=pest --show-mutations"
58 | },
59 | "extra": {
60 | "laravel": {
61 | "dont-discover": [
62 | "laravel/dusk"
63 | ]
64 | }
65 | },
66 | "config": {
67 | "optimize-autoloader": true,
68 | "preferred-install": "dist",
69 | "sort-packages": true
70 | },
71 | "minimum-stability": "dev",
72 | "prefer-stable": true
73 | }
74 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Application Environment
25 | |--------------------------------------------------------------------------
26 | |
27 | | This value determines the "environment" your application is currently
28 | | running in. This may determine how you prefer to configure various
29 | | services the application utilizes. Set this in your ".env" file.
30 | |
31 | */
32 |
33 | 'env' => env('APP_ENV', 'production'),
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Application Debug Mode
38 | |--------------------------------------------------------------------------
39 | |
40 | | When your application is in debug mode, detailed error messages with
41 | | stack traces will be shown on every error that occurs within your
42 | | application. If disabled, a simple generic error page is shown.
43 | |
44 | */
45 |
46 | 'debug' => (bool) env('APP_DEBUG', false),
47 |
48 | /*
49 | |--------------------------------------------------------------------------
50 | | Application URL
51 | |--------------------------------------------------------------------------
52 | |
53 | | This URL is used by the console to properly generate URLs when using
54 | | the Artisan command line tool. You should set this to the root of
55 | | your application so that it is used when running Artisan tasks.
56 | |
57 | */
58 |
59 | 'url' => env('APP_URL', 'http://localhost'),
60 |
61 | 'asset_url' => env('ASSET_URL', null),
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | Application Timezone
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the default timezone for your application, which
69 | | will be used by the PHP date and date-time functions. We have gone
70 | | ahead and set this to a sensible default for you out of the box.
71 | |
72 | */
73 |
74 | 'timezone' => 'UTC',
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Application Locale Configuration
79 | |--------------------------------------------------------------------------
80 | |
81 | | The application locale determines the default locale that will be used
82 | | by the translation service provider. You are free to set this value
83 | | to any of the locales which will be supported by the application.
84 | |
85 | */
86 |
87 | 'locale' => 'en',
88 |
89 | /*
90 | |--------------------------------------------------------------------------
91 | | Application Fallback Locale
92 | |--------------------------------------------------------------------------
93 | |
94 | | The fallback locale determines the locale to use when the current one
95 | | is not available. You may change the value to correspond to any of
96 | | the language folders that are provided through your application.
97 | |
98 | */
99 |
100 | 'fallback_locale' => 'en',
101 |
102 | /*
103 | |--------------------------------------------------------------------------
104 | | Faker Locale
105 | |--------------------------------------------------------------------------
106 | |
107 | | This locale will be used by the Faker PHP library when generating fake
108 | | data for your database seeds. For example, this will be used to get
109 | | localized telephone numbers, street address information and more.
110 | |
111 | */
112 |
113 | 'faker_locale' => 'en_US',
114 |
115 | /*
116 | |--------------------------------------------------------------------------
117 | | Encryption Key
118 | |--------------------------------------------------------------------------
119 | |
120 | | This key is used by the Illuminate encrypter service and should be set
121 | | to a random, 32 character string, otherwise these encrypted strings
122 | | will not be safe. Please do this before deploying an application!
123 | |
124 | */
125 |
126 | 'key' => env('APP_KEY'),
127 |
128 | 'cipher' => 'AES-256-CBC',
129 |
130 | /*
131 | |--------------------------------------------------------------------------
132 | | Autoloaded Service Providers
133 | |--------------------------------------------------------------------------
134 | |
135 | | The service providers listed here will be automatically loaded on the
136 | | request to your application. Feel free to add your own services to
137 | | this array to grant expanded functionality to your applications.
138 | |
139 | */
140 |
141 | 'providers' => [
142 |
143 | /*
144 | * Laravel Framework Service Providers...
145 | */
146 | Illuminate\Auth\AuthServiceProvider::class,
147 | Illuminate\Broadcasting\BroadcastServiceProvider::class,
148 | Illuminate\Bus\BusServiceProvider::class,
149 | Illuminate\Cache\CacheServiceProvider::class,
150 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
151 | Illuminate\Cookie\CookieServiceProvider::class,
152 | Illuminate\Database\DatabaseServiceProvider::class,
153 | Illuminate\Encryption\EncryptionServiceProvider::class,
154 | Illuminate\Filesystem\FilesystemServiceProvider::class,
155 | Illuminate\Foundation\Providers\FoundationServiceProvider::class,
156 | Illuminate\Hashing\HashServiceProvider::class,
157 | Illuminate\Mail\MailServiceProvider::class,
158 | Illuminate\Notifications\NotificationServiceProvider::class,
159 | Illuminate\Pagination\PaginationServiceProvider::class,
160 | Illuminate\Pipeline\PipelineServiceProvider::class,
161 | Illuminate\Queue\QueueServiceProvider::class,
162 | Illuminate\Redis\RedisServiceProvider::class,
163 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
164 | Illuminate\Session\SessionServiceProvider::class,
165 | Illuminate\Translation\TranslationServiceProvider::class,
166 | Illuminate\Validation\ValidationServiceProvider::class,
167 | Illuminate\View\ViewServiceProvider::class,
168 |
169 | /*
170 | * Package Service Providers...
171 | */
172 |
173 | /*
174 | * Application Service Providers...
175 | */
176 | App\Providers\AppServiceProvider::class,
177 | App\Providers\AuthServiceProvider::class,
178 | // App\Providers\BroadcastServiceProvider::class,
179 | App\Providers\EventServiceProvider::class,
180 | App\Providers\RouteServiceProvider::class,
181 |
182 | ],
183 |
184 | /*
185 | |--------------------------------------------------------------------------
186 | | Class Aliases
187 | |--------------------------------------------------------------------------
188 | |
189 | | This array of class aliases will be registered when this application
190 | | is started. However, feel free to register as many as you wish as
191 | | the aliases are "lazy" loaded so they don't hinder performance.
192 | |
193 | */
194 |
195 | 'aliases' => Facade::defaultAliases()->merge([
196 | // ...
197 | ])->toArray(),
198 |
199 | ];
200 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
19 | 'guard' => 'web',
20 | 'passwords' => 'users',
21 | ],
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Authentication Guards
26 | |--------------------------------------------------------------------------
27 | |
28 | | Next, you may define every authentication guard for your application.
29 | | Of course, a great default configuration has been defined for you
30 | | here which uses session storage and the Eloquent user provider.
31 | |
32 | | All authentication drivers have a user provider. This defines how the
33 | | users are actually retrieved out of your database or other storage
34 | | mechanisms used by this application to persist your user's data.
35 | |
36 | | Supported: "session"
37 | |
38 | */
39 |
40 | 'guards' => [
41 | 'web' => [
42 | 'driver' => 'session',
43 | 'provider' => 'users',
44 | ],
45 | ],
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | User Providers
50 | |--------------------------------------------------------------------------
51 | |
52 | | All authentication drivers have a user provider. This defines how the
53 | | users are actually retrieved out of your database or other storage
54 | | mechanisms used by this application to persist your user's data.
55 | |
56 | | If you have multiple user tables or models you may configure multiple
57 | | sources which represent each model / table. These sources may then
58 | | be assigned to any extra authentication guards you have defined.
59 | |
60 | | Supported: "database", "eloquent"
61 | |
62 | */
63 |
64 | 'providers' => [
65 | 'users' => [
66 | 'driver' => 'eloquent',
67 | 'model' => App\Models\User::class,
68 | ],
69 |
70 | // 'users' => [
71 | // 'driver' => 'database',
72 | // 'table' => 'users',
73 | // ],
74 | ],
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Resetting Passwords
79 | |--------------------------------------------------------------------------
80 | |
81 | | You may specify multiple password reset configurations if you have more
82 | | than one user table or model in the application and you want to have
83 | | separate password reset settings based on the specific user types.
84 | |
85 | | The expire time is the number of minutes that each reset token will be
86 | | considered valid. This security feature keeps tokens short-lived so
87 | | they have less time to be guessed. You may change this as needed.
88 | |
89 | */
90 |
91 | 'passwords' => [
92 | 'users' => [
93 | 'provider' => 'users',
94 | 'table' => 'password_resets',
95 | 'expire' => 60,
96 | 'throttle' => 60,
97 | ],
98 | ],
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Password Confirmation Timeout
103 | |--------------------------------------------------------------------------
104 | |
105 | | Here you may define the amount of seconds before a password confirmation
106 | | times out and the user is prompted to re-enter their password via the
107 | | confirmation screen. By default, the timeout lasts for three hours.
108 | |
109 | */
110 |
111 | 'password_timeout' => 10800,
112 |
113 | ];
114 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Broadcast Connections
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may define all of the broadcast connections that will be used
28 | | to broadcast events to other systems or over websockets. Samples of
29 | | each available type of connection are provided inside this array.
30 | |
31 | */
32 |
33 | 'connections' => [
34 |
35 | 'pusher' => [
36 | 'driver' => 'pusher',
37 | 'key' => env('PUSHER_APP_KEY'),
38 | 'secret' => env('PUSHER_APP_SECRET'),
39 | 'app_id' => env('PUSHER_APP_ID'),
40 | 'options' => [
41 | 'cluster' => env('PUSHER_APP_CLUSTER'),
42 | 'useTLS' => true,
43 | ],
44 | 'client_options' => [
45 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
46 | ],
47 | ],
48 |
49 | 'ably' => [
50 | 'driver' => 'ably',
51 | 'key' => env('ABLY_KEY'),
52 | ],
53 |
54 | 'redis' => [
55 | 'driver' => 'redis',
56 | 'connection' => 'default',
57 | ],
58 |
59 | 'log' => [
60 | 'driver' => 'log',
61 | ],
62 |
63 | 'null' => [
64 | 'driver' => 'null',
65 | ],
66 |
67 | ],
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Cache Stores
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may define all of the cache "stores" for your application as
28 | | well as their drivers. You may even define multiple stores for the
29 | | same cache driver to group types of items stored in your caches.
30 | |
31 | | Supported drivers: "apc", "array", "database", "file",
32 | | "memcached", "redis", "dynamodb", "octane", "null"
33 | |
34 | */
35 |
36 | 'stores' => [
37 |
38 | 'apc' => [
39 | 'driver' => 'apc',
40 | ],
41 |
42 | 'array' => [
43 | 'driver' => 'array',
44 | 'serialize' => false,
45 | ],
46 |
47 | 'database' => [
48 | 'driver' => 'database',
49 | 'table' => 'cache',
50 | 'connection' => null,
51 | 'lock_connection' => null,
52 | ],
53 |
54 | 'file' => [
55 | 'driver' => 'file',
56 | 'path' => storage_path('framework/cache/data'),
57 | ],
58 |
59 | 'memcached' => [
60 | 'driver' => 'memcached',
61 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
62 | 'sasl' => [
63 | env('MEMCACHED_USERNAME'),
64 | env('MEMCACHED_PASSWORD'),
65 | ],
66 | 'options' => [
67 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
68 | ],
69 | 'servers' => [
70 | [
71 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
72 | 'port' => env('MEMCACHED_PORT', 11211),
73 | 'weight' => 100,
74 | ],
75 | ],
76 | ],
77 |
78 | 'redis' => [
79 | 'driver' => 'redis',
80 | 'connection' => 'cache',
81 | 'lock_connection' => 'default',
82 | ],
83 |
84 | 'dynamodb' => [
85 | 'driver' => 'dynamodb',
86 | 'key' => env('AWS_ACCESS_KEY_ID'),
87 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
88 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
89 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
90 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
91 | ],
92 |
93 | 'octane' => [
94 | 'driver' => 'octane',
95 | ],
96 |
97 | ],
98 |
99 | /*
100 | |--------------------------------------------------------------------------
101 | | Cache Key Prefix
102 | |--------------------------------------------------------------------------
103 | |
104 | | When utilizing a RAM based store such as APC or Memcached, there might
105 | | be other applications utilizing the same cache. So, we'll specify a
106 | | value to get prefixed to all our keys so we can avoid collisions.
107 | |
108 | */
109 |
110 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
111 |
112 | ];
113 |
--------------------------------------------------------------------------------
/config/cors.php:
--------------------------------------------------------------------------------
1 | ['api/*', 'sanctum/csrf-cookie'],
21 |
22 | 'allowed_methods' => ['*'],
23 |
24 | 'allowed_origins' => ['*'],
25 |
26 | 'allowed_origins_patterns' => [],
27 |
28 | 'allowed_headers' => ['*'],
29 |
30 | 'exposed_headers' => [],
31 |
32 | 'max_age' => 0,
33 |
34 | 'supports_credentials' => false,
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Database Connections
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here are each of the database connections setup for your application.
28 | | Of course, examples of configuring each database platform that is
29 | | supported by Laravel is shown below to make development simple.
30 | |
31 | |
32 | | All database work in Laravel is done through the PHP PDO facilities
33 | | so make sure you have the driver for your particular database of
34 | | choice installed on your machine before you begin development.
35 | |
36 | */
37 |
38 | 'connections' => [
39 |
40 | 'sqlite' => [
41 | 'driver' => 'sqlite',
42 | 'url' => env('DATABASE_URL'),
43 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
44 | 'prefix' => '',
45 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
46 | ],
47 |
48 | 'mysql' => [
49 | 'driver' => 'mysql',
50 | 'url' => env('DATABASE_URL'),
51 | 'host' => env('DB_HOST', '127.0.0.1'),
52 | 'port' => env('DB_PORT', '3306'),
53 | 'database' => env('DB_DATABASE', 'forge'),
54 | 'username' => env('DB_USERNAME', 'forge'),
55 | 'password' => env('DB_PASSWORD', ''),
56 | 'unix_socket' => env('DB_SOCKET', ''),
57 | 'charset' => 'utf8mb4',
58 | 'collation' => 'utf8mb4_unicode_ci',
59 | 'prefix' => '',
60 | 'prefix_indexes' => true,
61 | 'strict' => true,
62 | 'engine' => null,
63 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
64 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
65 | ]) : [],
66 | ],
67 |
68 | 'pgsql' => [
69 | 'driver' => 'pgsql',
70 | 'url' => env('DATABASE_URL'),
71 | 'host' => env('DB_HOST', '127.0.0.1'),
72 | 'port' => env('DB_PORT', '5432'),
73 | 'database' => env('DB_DATABASE', 'forge'),
74 | 'username' => env('DB_USERNAME', 'forge'),
75 | 'password' => env('DB_PASSWORD', ''),
76 | 'charset' => 'utf8',
77 | 'prefix' => '',
78 | 'prefix_indexes' => true,
79 | 'search_path' => 'public',
80 | 'sslmode' => 'prefer',
81 | ],
82 |
83 | 'sqlsrv' => [
84 | 'driver' => 'sqlsrv',
85 | 'url' => env('DATABASE_URL'),
86 | 'host' => env('DB_HOST', 'localhost'),
87 | 'port' => env('DB_PORT', '1433'),
88 | 'database' => env('DB_DATABASE', 'forge'),
89 | 'username' => env('DB_USERNAME', 'forge'),
90 | 'password' => env('DB_PASSWORD', ''),
91 | 'charset' => 'utf8',
92 | 'prefix' => '',
93 | 'prefix_indexes' => true,
94 | ],
95 |
96 | ],
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Migration Repository Table
101 | |--------------------------------------------------------------------------
102 | |
103 | | This table keeps track of all the migrations that have already run for
104 | | your application. Using this information, we can determine which of
105 | | the migrations on disk haven't actually been run in the database.
106 | |
107 | */
108 |
109 | 'migrations' => 'migrations',
110 |
111 | /*
112 | |--------------------------------------------------------------------------
113 | | Redis Databases
114 | |--------------------------------------------------------------------------
115 | |
116 | | Redis is an open source, fast, and advanced key-value store that also
117 | | provides a richer body of commands than a typical key-value system
118 | | such as APC or Memcached. Laravel makes it easy to dig right in.
119 | |
120 | */
121 |
122 | 'redis' => [
123 |
124 | 'client' => env('REDIS_CLIENT', 'phpredis'),
125 |
126 | 'options' => [
127 | 'cluster' => env('REDIS_CLUSTER', 'redis'),
128 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
129 | ],
130 |
131 | 'default' => [
132 | 'url' => env('REDIS_URL'),
133 | 'host' => env('REDIS_HOST', '127.0.0.1'),
134 | 'password' => env('REDIS_PASSWORD'),
135 | 'port' => env('REDIS_PORT', '6379'),
136 | 'database' => env('REDIS_DB', '0'),
137 | ],
138 |
139 | 'cache' => [
140 | 'url' => env('REDIS_URL'),
141 | 'host' => env('REDIS_HOST', '127.0.0.1'),
142 | 'password' => env('REDIS_PASSWORD'),
143 | 'port' => env('REDIS_PORT', '6379'),
144 | 'database' => env('REDIS_CACHE_DB', '1'),
145 | ],
146 |
147 | ],
148 |
149 | ];
150 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DISK', 'local'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Filesystem Disks
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure as many filesystem "disks" as you wish, and you
26 | | may even configure multiple disks of the same driver. Defaults have
27 | | been setup for each driver as an example of the required options.
28 | |
29 | | Supported Drivers: "local", "ftp", "sftp", "s3"
30 | |
31 | */
32 |
33 | 'disks' => [
34 |
35 | 'local' => [
36 | 'driver' => 'local',
37 | 'root' => storage_path('app'),
38 | ],
39 |
40 | 'public' => [
41 | 'driver' => 'local',
42 | 'root' => storage_path('app/public'),
43 | 'url' => env('APP_URL').'/storage',
44 | 'visibility' => 'public',
45 | ],
46 |
47 | 's3' => [
48 | 'driver' => 's3',
49 | 'key' => env('AWS_ACCESS_KEY_ID'),
50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
51 | 'region' => env('AWS_DEFAULT_REGION'),
52 | 'bucket' => env('AWS_BUCKET'),
53 | 'url' => env('AWS_URL'),
54 | 'endpoint' => env('AWS_ENDPOINT'),
55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
56 | ],
57 |
58 | ],
59 |
60 | /*
61 | |--------------------------------------------------------------------------
62 | | Symbolic Links
63 | |--------------------------------------------------------------------------
64 | |
65 | | Here you may configure the symbolic links that will be created when the
66 | | `storage:link` Artisan command is executed. The array keys should be
67 | | the locations of the links and the values should be their targets.
68 | |
69 | */
70 |
71 | 'links' => [
72 | public_path('storage') => storage_path('app/public'),
73 | ],
74 |
75 | ];
76 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Bcrypt Options
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may specify the configuration options that should be used when
28 | | passwords are hashed using the Bcrypt algorithm. This will allow you
29 | | to control the amount of time it takes to hash the given password.
30 | |
31 | */
32 |
33 | 'bcrypt' => [
34 | 'rounds' => env('BCRYPT_ROUNDS', 10),
35 | ],
36 |
37 | /*
38 | |--------------------------------------------------------------------------
39 | | Argon Options
40 | |--------------------------------------------------------------------------
41 | |
42 | | Here you may specify the configuration options that should be used when
43 | | passwords are hashed using the Argon algorithm. These will allow you
44 | | to control the amount of time it takes to hash the given password.
45 | |
46 | */
47 |
48 | 'argon' => [
49 | 'memory' => 65536,
50 | 'threads' => 1,
51 | 'time' => 4,
52 | ],
53 |
54 | ];
55 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Deprecations Log Channel
27 | |--------------------------------------------------------------------------
28 | |
29 | | This option controls the log channel that should be used to log warnings
30 | | regarding deprecated PHP and library features. This allows you to get
31 | | your application ready for upcoming major versions of dependencies.
32 | |
33 | */
34 |
35 | 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
36 |
37 | /*
38 | |--------------------------------------------------------------------------
39 | | Log Channels
40 | |--------------------------------------------------------------------------
41 | |
42 | | Here you may configure the log channels for your application. Out of
43 | | the box, Laravel uses the Monolog PHP logging library. This gives
44 | | you a variety of powerful log handlers / formatters to utilize.
45 | |
46 | | Available Drivers: "single", "daily", "slack", "syslog",
47 | | "errorlog", "monolog",
48 | | "custom", "stack"
49 | |
50 | */
51 |
52 | 'channels' => [
53 | 'stack' => [
54 | 'driver' => 'stack',
55 | 'channels' => ['single'],
56 | 'ignore_exceptions' => false,
57 | ],
58 |
59 | 'single' => [
60 | 'driver' => 'single',
61 | 'path' => storage_path('logs/laravel.log'),
62 | 'level' => env('LOG_LEVEL', 'debug'),
63 | ],
64 |
65 | 'daily' => [
66 | 'driver' => 'daily',
67 | 'path' => storage_path('logs/laravel.log'),
68 | 'level' => env('LOG_LEVEL', 'debug'),
69 | 'days' => 14,
70 | ],
71 |
72 | 'slack' => [
73 | 'driver' => 'slack',
74 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
75 | 'username' => 'Laravel Log',
76 | 'emoji' => ':boom:',
77 | 'level' => env('LOG_LEVEL', 'critical'),
78 | ],
79 |
80 | 'papertrail' => [
81 | 'driver' => 'monolog',
82 | 'level' => env('LOG_LEVEL', 'debug'),
83 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
84 | 'handler_with' => [
85 | 'host' => env('PAPERTRAIL_URL'),
86 | 'port' => env('PAPERTRAIL_PORT'),
87 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
88 | ],
89 | ],
90 |
91 | 'stderr' => [
92 | 'driver' => 'monolog',
93 | 'level' => env('LOG_LEVEL', 'debug'),
94 | 'handler' => StreamHandler::class,
95 | 'formatter' => env('LOG_STDERR_FORMATTER'),
96 | 'with' => [
97 | 'stream' => 'php://stderr',
98 | ],
99 | ],
100 |
101 | 'syslog' => [
102 | 'driver' => 'syslog',
103 | 'level' => env('LOG_LEVEL', 'debug'),
104 | ],
105 |
106 | 'errorlog' => [
107 | 'driver' => 'errorlog',
108 | 'level' => env('LOG_LEVEL', 'debug'),
109 | ],
110 |
111 | 'null' => [
112 | 'driver' => 'monolog',
113 | 'handler' => NullHandler::class,
114 | ],
115 |
116 | 'emergency' => [
117 | 'path' => storage_path('logs/laravel.log'),
118 | ],
119 | ],
120 |
121 | ];
122 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_MAILER', 'smtp'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Mailer Configurations
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure all of the mailers used by your application plus
26 | | their respective settings. Several examples have been configured for
27 | | you and you are free to add your own as your application requires.
28 | |
29 | | Laravel supports a variety of mail "transport" drivers to be used while
30 | | sending an e-mail. You will specify which one you are using for your
31 | | mailers below. You are free to add additional mailers as required.
32 | |
33 | | Supported: "smtp", "sendmail", "mailgun", "ses",
34 | | "postmark", "log", "array", "failover"
35 | |
36 | */
37 |
38 | 'mailers' => [
39 | 'smtp' => [
40 | 'transport' => 'smtp',
41 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
42 | 'port' => env('MAIL_PORT', 587),
43 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
44 | 'username' => env('MAIL_USERNAME'),
45 | 'password' => env('MAIL_PASSWORD'),
46 | 'timeout' => null,
47 | ],
48 |
49 | 'ses' => [
50 | 'transport' => 'ses',
51 | ],
52 |
53 | 'mailgun' => [
54 | 'transport' => 'mailgun',
55 | ],
56 |
57 | 'postmark' => [
58 | 'transport' => 'postmark',
59 | ],
60 |
61 | 'sendmail' => [
62 | 'transport' => 'sendmail',
63 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
64 | ],
65 |
66 | 'log' => [
67 | 'transport' => 'log',
68 | 'channel' => env('MAIL_LOG_CHANNEL'),
69 | ],
70 |
71 | 'array' => [
72 | 'transport' => 'array',
73 | ],
74 |
75 | 'failover' => [
76 | 'transport' => 'failover',
77 | 'mailers' => [
78 | 'smtp',
79 | 'log',
80 | ],
81 | ],
82 | ],
83 |
84 | /*
85 | |--------------------------------------------------------------------------
86 | | Global "From" Address
87 | |--------------------------------------------------------------------------
88 | |
89 | | You may wish for all e-mails sent by your application to be sent from
90 | | the same address. Here, you may specify a name and address that is
91 | | used globally for all e-mails that are sent by your application.
92 | |
93 | */
94 |
95 | 'from' => [
96 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
97 | 'name' => env('MAIL_FROM_NAME', 'Example'),
98 | ],
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Markdown Mail Settings
103 | |--------------------------------------------------------------------------
104 | |
105 | | If you are using Markdown based email rendering, you may configure your
106 | | theme and component paths here, allowing you to customize the design
107 | | of the emails. Or, you may simply stick with the Laravel defaults!
108 | |
109 | */
110 |
111 | 'markdown' => [
112 | 'theme' => 'default',
113 |
114 | 'paths' => [
115 | resource_path('views/vendor/mail'),
116 | ],
117 | ],
118 |
119 | ];
120 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
30 | |
31 | */
32 |
33 | 'connections' => [
34 |
35 | 'sync' => [
36 | 'driver' => 'sync',
37 | ],
38 |
39 | 'database' => [
40 | 'driver' => 'database',
41 | 'table' => 'jobs',
42 | 'queue' => 'default',
43 | 'retry_after' => 90,
44 | 'after_commit' => false,
45 | ],
46 |
47 | 'beanstalkd' => [
48 | 'driver' => 'beanstalkd',
49 | 'host' => 'localhost',
50 | 'queue' => 'default',
51 | 'retry_after' => 90,
52 | 'block_for' => 0,
53 | 'after_commit' => false,
54 | ],
55 |
56 | 'sqs' => [
57 | 'driver' => 'sqs',
58 | 'key' => env('AWS_ACCESS_KEY_ID'),
59 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
60 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
61 | 'queue' => env('SQS_QUEUE', 'default'),
62 | 'suffix' => env('SQS_SUFFIX'),
63 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
64 | 'after_commit' => false,
65 | ],
66 |
67 | 'redis' => [
68 | 'driver' => 'redis',
69 | 'connection' => 'default',
70 | 'queue' => env('REDIS_QUEUE', 'default'),
71 | 'retry_after' => 90,
72 | 'block_for' => null,
73 | 'after_commit' => false,
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Failed Queue Jobs
81 | |--------------------------------------------------------------------------
82 | |
83 | | These options configure the behavior of failed queue job logging so you
84 | | can control which database and table are used to store the jobs that
85 | | have failed. You may change them to any database / table you wish.
86 | |
87 | */
88 |
89 | 'failed' => [
90 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
91 | 'database' => env('DB_CONNECTION', 'mysql'),
92 | 'table' => 'failed_jobs',
93 | ],
94 |
95 | ];
96 |
--------------------------------------------------------------------------------
/config/sanctum.php:
--------------------------------------------------------------------------------
1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
19 | '%s%s',
20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
21 | env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
22 | ))),
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Sanctum Guards
27 | |--------------------------------------------------------------------------
28 | |
29 | | This array contains the authentication guards that will be checked when
30 | | Sanctum is trying to authenticate a request. If none of these guards
31 | | are able to authenticate the request, Sanctum will use the bearer
32 | | token that's present on an incoming request for authentication.
33 | |
34 | */
35 |
36 | 'guard' => ['web'],
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Expiration Minutes
41 | |--------------------------------------------------------------------------
42 | |
43 | | This value controls the number of minutes until an issued token will be
44 | | considered expired. If this value is null, personal access tokens do
45 | | not expire. This won't tweak the lifetime of first-party sessions.
46 | |
47 | */
48 |
49 | 'expiration' => null,
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Sanctum Middleware
54 | |--------------------------------------------------------------------------
55 | |
56 | | When authenticating your first-party SPA with Sanctum you may need to
57 | | customize some of the middleware Sanctum uses while processing the
58 | | request. You may change the middleware listed below as required.
59 | |
60 | */
61 |
62 | 'middleware' => [
63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
65 | ],
66 |
67 | ];
68 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
20 | 'domain' => env('MAILGUN_DOMAIN'),
21 | 'secret' => env('MAILGUN_SECRET'),
22 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
23 | ],
24 |
25 | 'postmark' => [
26 | 'token' => env('POSTMARK_TOKEN'),
27 | ],
28 |
29 | 'ses' => [
30 | 'key' => env('AWS_ACCESS_KEY_ID'),
31 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
32 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
33 | ],
34 |
35 | ];
36 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
24 |
25 | /*
26 | |--------------------------------------------------------------------------
27 | | Session Lifetime
28 | |--------------------------------------------------------------------------
29 | |
30 | | Here you may specify the number of minutes that you wish the session
31 | | to be allowed to remain idle before it expires. If you want them
32 | | to immediately expire on the browser closing, set that option.
33 | |
34 | */
35 |
36 | 'lifetime' => env('SESSION_LIFETIME', 120),
37 |
38 | 'expire_on_close' => false,
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Session Encryption
43 | |--------------------------------------------------------------------------
44 | |
45 | | This option allows you to easily specify that all of your session data
46 | | should be encrypted before it is stored. All encryption will be run
47 | | automatically by Laravel and you can use the Session like normal.
48 | |
49 | */
50 |
51 | 'encrypt' => false,
52 |
53 | /*
54 | |--------------------------------------------------------------------------
55 | | Session File Location
56 | |--------------------------------------------------------------------------
57 | |
58 | | When using the native session driver, we need a location where session
59 | | files may be stored. A default has been set for you but a different
60 | | location may be specified. This is only needed for file sessions.
61 | |
62 | */
63 |
64 | 'files' => storage_path('framework/sessions'),
65 |
66 | /*
67 | |--------------------------------------------------------------------------
68 | | Session Database Connection
69 | |--------------------------------------------------------------------------
70 | |
71 | | When using the "database" or "redis" session drivers, you may specify a
72 | | connection that should be used to manage these sessions. This should
73 | | correspond to a connection in your database configuration options.
74 | |
75 | */
76 |
77 | 'connection' => env('SESSION_CONNECTION'),
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Session Database Table
82 | |--------------------------------------------------------------------------
83 | |
84 | | When using the "database" session driver, you may specify the table we
85 | | should use to manage the sessions. Of course, a sensible default is
86 | | provided for you; however, you are free to change this as needed.
87 | |
88 | */
89 |
90 | 'table' => 'sessions',
91 |
92 | /*
93 | |--------------------------------------------------------------------------
94 | | Session Cache Store
95 | |--------------------------------------------------------------------------
96 | |
97 | | While using one of the framework's cache driven session backends you may
98 | | list a cache store that should be used for these sessions. This value
99 | | must match with one of the application's configured cache "stores".
100 | |
101 | | Affects: "apc", "dynamodb", "memcached", "redis"
102 | |
103 | */
104 |
105 | 'store' => env('SESSION_STORE'),
106 |
107 | /*
108 | |--------------------------------------------------------------------------
109 | | Session Sweeping Lottery
110 | |--------------------------------------------------------------------------
111 | |
112 | | Some session drivers must manually sweep their storage location to get
113 | | rid of old sessions from storage. Here are the chances that it will
114 | | happen on a given request. By default, the odds are 2 out of 100.
115 | |
116 | */
117 |
118 | 'lottery' => [2, 100],
119 |
120 | /*
121 | |--------------------------------------------------------------------------
122 | | Session Cookie Name
123 | |--------------------------------------------------------------------------
124 | |
125 | | Here you may change the name of the cookie used to identify a session
126 | | instance by ID. The name specified here will get used every time a
127 | | new session cookie is created by the framework for every driver.
128 | |
129 | */
130 |
131 | 'cookie' => env(
132 | 'SESSION_COOKIE',
133 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
134 | ),
135 |
136 | /*
137 | |--------------------------------------------------------------------------
138 | | Session Cookie Path
139 | |--------------------------------------------------------------------------
140 | |
141 | | The session cookie path determines the path for which the cookie will
142 | | be regarded as available. Typically, this will be the root path of
143 | | your application but you are free to change this when necessary.
144 | |
145 | */
146 |
147 | 'path' => '/',
148 |
149 | /*
150 | |--------------------------------------------------------------------------
151 | | Session Cookie Domain
152 | |--------------------------------------------------------------------------
153 | |
154 | | Here you may change the domain of the cookie used to identify a session
155 | | in your application. This will determine which domains the cookie is
156 | | available to in your application. A sensible default has been set.
157 | |
158 | */
159 |
160 | 'domain' => env('SESSION_DOMAIN'),
161 |
162 | /*
163 | |--------------------------------------------------------------------------
164 | | HTTPS Only Cookies
165 | |--------------------------------------------------------------------------
166 | |
167 | | By setting this option to true, session cookies will only be sent back
168 | | to the server if the browser has a HTTPS connection. This will keep
169 | | the cookie from being sent to you when it can't be done securely.
170 | |
171 | */
172 |
173 | 'secure' => env('SESSION_SECURE_COOKIE'),
174 |
175 | /*
176 | |--------------------------------------------------------------------------
177 | | HTTP Access Only
178 | |--------------------------------------------------------------------------
179 | |
180 | | Setting this value to true will prevent JavaScript from accessing the
181 | | value of the cookie and the cookie will only be accessible through
182 | | the HTTP protocol. You are free to modify this option if needed.
183 | |
184 | */
185 |
186 | 'http_only' => true,
187 |
188 | /*
189 | |--------------------------------------------------------------------------
190 | | Same-Site Cookies
191 | |--------------------------------------------------------------------------
192 | |
193 | | This option determines how your cookies behave when cross-site requests
194 | | take place, and can be used to mitigate CSRF attacks. By default, we
195 | | will set this value to "lax" since this is a secure default value.
196 | |
197 | | Supported: "lax", "strict", "none", null
198 | |
199 | */
200 |
201 | 'same_site' => 'lax',
202 |
203 | ];
204 |
--------------------------------------------------------------------------------
/config/treblle.php:
--------------------------------------------------------------------------------
1 | env('TREBLLE_API_KEY'),
10 |
11 | /*
12 | * A valid Treblle project ID. Create your first project on https://treblle.com/
13 | */
14 | 'project_id' => env('TREBLLE_PROJECT_ID'),
15 |
16 | /*
17 | * Define which environments should Treblle ignore and not monitor
18 | */
19 | 'ignored_environments' => env('TREBLLE_IGNORED_ENV', 'dev,test'),
20 |
21 | /*
22 | * Define which fields should be masked before leaving the server
23 | */
24 | 'masked_fields' => [
25 | 'password',
26 | 'pwd',
27 | 'secret',
28 | 'password_confirmation',
29 | 'cc',
30 | 'card_number',
31 | 'ccv',
32 | 'ssn',
33 | 'credit_score',
34 | 'api_key',
35 | 'token',
36 | ],
37 | ];
38 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
19 | resource_path('views'),
20 | ],
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Compiled View Path
25 | |--------------------------------------------------------------------------
26 | |
27 | | This option determines where all the compiled Blade templates will be
28 | | stored for your application. Typically, this is within the storage
29 | | directory. However, as usual, you are free to change this value.
30 | |
31 | */
32 |
33 | 'compiled' => env(
34 | 'VIEW_COMPILED_PATH',
35 | realpath(storage_path('framework/views'))
36 | ),
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite*
2 |
--------------------------------------------------------------------------------
/database/factories/PostFactory.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | class PostFactory extends Factory
15 | {
16 | /**
17 | * Define the model's default state.
18 | *
19 | * @return array
20 | */
21 | public function definition()
22 | {
23 | return [
24 | 'user_id' => User::factory(),
25 | 'uuid' => $this->faker->uuid(),
26 | 'title' => $this->faker->title(),
27 | 'content' => $this->faker->paragraphs(3, true),
28 | ];
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | class UserFactory extends Factory
15 | {
16 | /**
17 | * Define the model's default state.
18 | *
19 | * @return array
20 | */
21 | public function definition()
22 | {
23 | return [
24 | 'uuid' => $this->faker->uuid(),
25 | 'name' => $this->faker->name(),
26 | 'email' => $this->faker->unique()->safeEmail(),
27 | 'email_verified_at' => now(),
28 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
29 | 'remember_token' => Str::random(10),
30 | ];
31 | }
32 |
33 | /**
34 | * Indicate that the model's email address should be unverified.
35 | *
36 | * @return \Illuminate\Database\Eloquent\Factories\Factory
37 | */
38 | public function unverified()
39 | {
40 | return $this->state(function (array $attributes) {
41 | return [
42 | 'email_verified_at' => null,
43 | ];
44 | });
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | id();
19 | $table->uuid()->index();
20 | $table->string('name');
21 | $table->string('email')->unique();
22 | $table->timestamp('email_verified_at')->nullable();
23 | $table->string('password');
24 | $table->rememberToken();
25 | $table->timestamps();
26 | });
27 | }
28 |
29 | /**
30 | * Reverse the migrations.
31 | *
32 | * @return void
33 | */
34 | public function down()
35 | {
36 | Schema::dropIfExists('users');
37 | }
38 | };
39 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
19 | $table->string('token');
20 | $table->timestamp('created_at')->nullable();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::dropIfExists('password_resets');
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/database/migrations/2019_08_19_000000_create_failed_jobs_table.php:
--------------------------------------------------------------------------------
1 | id();
19 | $table->string('uuid')->unique();
20 | $table->text('connection');
21 | $table->text('queue');
22 | $table->longText('payload');
23 | $table->longText('exception');
24 | $table->timestamp('failed_at')->useCurrent();
25 | });
26 | }
27 |
28 | /**
29 | * Reverse the migrations.
30 | *
31 | * @return void
32 | */
33 | public function down()
34 | {
35 | Schema::dropIfExists('failed_jobs');
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php:
--------------------------------------------------------------------------------
1 | id();
19 | $table->morphs('tokenable');
20 | $table->string('name');
21 | $table->string('token', 64)->unique();
22 | $table->text('abilities')->nullable();
23 | $table->timestamp('last_used_at')->nullable();
24 | $table->timestamps();
25 | });
26 | }
27 |
28 | /**
29 | * Reverse the migrations.
30 | *
31 | * @return void
32 | */
33 | public function down()
34 | {
35 | Schema::dropIfExists('personal_access_tokens');
36 | }
37 | };
38 |
--------------------------------------------------------------------------------
/database/migrations/2022_02_16_143104_create_posts_table.php:
--------------------------------------------------------------------------------
1 | id();
15 | $table->uuid()->index();
16 | $table->foreignIdFor(User::class)->constrained();
17 | $table->string('title');
18 | $table->longText('content');
19 | $table->timestamps();
20 | });
21 | }
22 | };
23 |
--------------------------------------------------------------------------------
/database/seeders/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | create();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/infection.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "vendor/infection/infection/resources/schema.json",
3 | "source": {
4 | "directories": [
5 | "app"
6 | ]
7 | },
8 | "phpUnit": {
9 | "configDir": ""
10 | },
11 | "mutators": {
12 | "@default": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lang/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "The :attribute must contain at least one letter.": "The :attribute must contain at least one letter.",
3 | "The :attribute must contain at least one number.": "The :attribute must contain at least one number.",
4 | "The :attribute must contain at least one symbol.": "The :attribute must contain at least one symbol.",
5 | "The :attribute must contain at least one uppercase and one lowercase letter.": "The :attribute must contain at least one uppercase and one lowercase letter.",
6 | "The given :attribute has appeared in a data leak. Please choose a different :attribute.": "The given :attribute has appeared in a data leak. Please choose a different :attribute."
7 | }
8 |
--------------------------------------------------------------------------------
/lang/en/artisan.php:
--------------------------------------------------------------------------------
1 | [
8 | 'description' => 'Create a new user',
9 | 'dialogs' => [
10 | 'confirm_before_executing' => 'Do you want to proceed?',
11 | ],
12 | 'alerts' => [
13 | 'confirmation' => 'User created!',
14 | ],
15 | 'questions' => [
16 | 'name' => 'What is the name?',
17 | 'email' => 'What is the email?',
18 | 'password' => 'What is the password?',
19 | ],
20 | ],
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/lang/en/auth.php:
--------------------------------------------------------------------------------
1 | 'These credentials do not match our records.',
19 | 'password' => 'The provided password is incorrect.',
20 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
19 | 'next' => 'Next »',
20 |
21 | ];
22 |
--------------------------------------------------------------------------------
/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Your password has been reset!',
19 | 'sent' => 'We have emailed your password reset link!',
20 | 'throttled' => 'Please wait before retrying.',
21 | 'token' => 'This password reset token is invalid.',
22 | 'user' => "We can't find a user with that email address.",
23 |
24 | ];
25 |
--------------------------------------------------------------------------------
/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | 'The :attribute must be accepted.',
19 | 'accepted_if' => 'The :attribute must be accepted when :other is :value.',
20 | 'active_url' => 'The :attribute is not a valid URL.',
21 | 'after' => 'The :attribute must be a date after :date.',
22 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
23 | 'alpha' => 'The :attribute must only contain letters.',
24 | 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.',
25 | 'alpha_num' => 'The :attribute must only contain letters and numbers.',
26 | 'array' => 'The :attribute must be an array.',
27 | 'before' => 'The :attribute must be a date before :date.',
28 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
29 | 'between' => [
30 | 'numeric' => 'The :attribute must be between :min and :max.',
31 | 'file' => 'The :attribute must be between :min and :max kilobytes.',
32 | 'string' => 'The :attribute must be between :min and :max characters.',
33 | 'array' => 'The :attribute must have between :min and :max items.',
34 | ],
35 | 'boolean' => 'The :attribute field must be true or false.',
36 | 'confirmed' => 'The :attribute confirmation does not match.',
37 | 'current_password' => 'The password is incorrect.',
38 | 'date' => 'The :attribute is not a valid date.',
39 | 'date_equals' => 'The :attribute must be a date equal to :date.',
40 | 'date_format' => 'The :attribute does not match the format :format.',
41 | 'declined' => 'The :attribute must be declined.',
42 | 'declined_if' => 'The :attribute must be declined when :other is :value.',
43 | 'different' => 'The :attribute and :other must be different.',
44 | 'digits' => 'The :attribute must be :digits digits.',
45 | 'digits_between' => 'The :attribute must be between :min and :max digits.',
46 | 'dimensions' => 'The :attribute has invalid image dimensions.',
47 | 'distinct' => 'The :attribute field has a duplicate value.',
48 | 'email' => 'The :attribute must be a valid email address.',
49 | 'ends_with' => 'The :attribute must end with one of the following: :values.',
50 | 'enum' => 'The selected :attribute is invalid.',
51 | 'exists' => 'The selected :attribute is invalid.',
52 | 'file' => 'The :attribute must be a file.',
53 | 'filled' => 'The :attribute field must have a value.',
54 | 'gt' => [
55 | 'numeric' => 'The :attribute must be greater than :value.',
56 | 'file' => 'The :attribute must be greater than :value kilobytes.',
57 | 'string' => 'The :attribute must be greater than :value characters.',
58 | 'array' => 'The :attribute must have more than :value items.',
59 | ],
60 | 'gte' => [
61 | 'numeric' => 'The :attribute must be greater than or equal to :value.',
62 | 'file' => 'The :attribute must be greater than or equal to :value kilobytes.',
63 | 'string' => 'The :attribute must be greater than or equal to :value characters.',
64 | 'array' => 'The :attribute must have :value items or more.',
65 | ],
66 | 'image' => 'The :attribute must be an image.',
67 | 'in' => 'The selected :attribute is invalid.',
68 | 'in_array' => 'The :attribute field does not exist in :other.',
69 | 'integer' => 'The :attribute must be an integer.',
70 | 'ip' => 'The :attribute must be a valid IP address.',
71 | 'ipv4' => 'The :attribute must be a valid IPv4 address.',
72 | 'ipv6' => 'The :attribute must be a valid IPv6 address.',
73 | 'json' => 'The :attribute must be a valid JSON string.',
74 | 'lt' => [
75 | 'numeric' => 'The :attribute must be less than :value.',
76 | 'file' => 'The :attribute must be less than :value kilobytes.',
77 | 'string' => 'The :attribute must be less than :value characters.',
78 | 'array' => 'The :attribute must have less than :value items.',
79 | ],
80 | 'lte' => [
81 | 'numeric' => 'The :attribute must be less than or equal to :value.',
82 | 'file' => 'The :attribute must be less than or equal to :value kilobytes.',
83 | 'string' => 'The :attribute must be less than or equal to :value characters.',
84 | 'array' => 'The :attribute must not have more than :value items.',
85 | ],
86 | 'mac_address' => 'The :attribute must be a valid MAC address.',
87 | 'max' => [
88 | 'numeric' => 'The :attribute must not be greater than :max.',
89 | 'file' => 'The :attribute must not be greater than :max kilobytes.',
90 | 'string' => 'The :attribute must not be greater than :max characters.',
91 | 'array' => 'The :attribute must not have more than :max items.',
92 | ],
93 | 'mimes' => 'The :attribute must be a file of type: :values.',
94 | 'mimetypes' => 'The :attribute must be a file of type: :values.',
95 | 'min' => [
96 | 'numeric' => 'The :attribute must be at least :min.',
97 | 'file' => 'The :attribute must be at least :min kilobytes.',
98 | 'string' => 'The :attribute must be at least :min characters.',
99 | 'array' => 'The :attribute must have at least :min items.',
100 | ],
101 | 'multiple_of' => 'The :attribute must be a multiple of :value.',
102 | 'not_in' => 'The selected :attribute is invalid.',
103 | 'not_regex' => 'The :attribute format is invalid.',
104 | 'numeric' => 'The :attribute must be a number.',
105 | 'password' => 'The password is incorrect.',
106 | 'present' => 'The :attribute field must be present.',
107 | 'prohibited' => 'The :attribute field is prohibited.',
108 | 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
109 | 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',
110 | 'prohibits' => 'The :attribute field prohibits :other from being present.',
111 | 'regex' => 'The :attribute format is invalid.',
112 | 'required' => 'The :attribute field is required.',
113 | 'required_array_keys' => 'The :attribute field must contain entries for: :values.',
114 | 'required_if' => 'The :attribute field is required when :other is :value.',
115 | 'required_unless' => 'The :attribute field is required unless :other is in :values.',
116 | 'required_with' => 'The :attribute field is required when :values is present.',
117 | 'required_with_all' => 'The :attribute field is required when :values are present.',
118 | 'required_without' => 'The :attribute field is required when :values is not present.',
119 | 'required_without_all' => 'The :attribute field is required when none of :values are present.',
120 | 'same' => 'The :attribute and :other must match.',
121 | 'size' => [
122 | 'numeric' => 'The :attribute must be :size.',
123 | 'file' => 'The :attribute must be :size kilobytes.',
124 | 'string' => 'The :attribute must be :size characters.',
125 | 'array' => 'The :attribute must contain :size items.',
126 | ],
127 | 'starts_with' => 'The :attribute must start with one of the following: :values.',
128 | 'string' => 'The :attribute must be a string.',
129 | 'timezone' => 'The :attribute must be a valid timezone.',
130 | 'unique' => 'The :attribute has already been taken.',
131 | 'uploaded' => 'The :attribute failed to upload.',
132 | 'url' => 'The :attribute must be a valid URL.',
133 | 'uuid' => 'The :attribute must be a valid UUID.',
134 |
135 | 'credentials' => 'The provided credentials are incorrect.',
136 |
137 | /*
138 | |--------------------------------------------------------------------------
139 | | Custom Validation Language Lines
140 | |--------------------------------------------------------------------------
141 | |
142 | | Here you may specify custom validation messages for attributes using the
143 | | convention "attribute.rule" to name the lines. This makes it quick to
144 | | specify a specific custom language line for a given attribute rule.
145 | |
146 | */
147 |
148 | 'custom' => [
149 | 'attribute-name' => [
150 | 'rule-name' => 'custom-message',
151 | ],
152 | ],
153 |
154 | /*
155 | |--------------------------------------------------------------------------
156 | | Custom Validation Attributes
157 | |--------------------------------------------------------------------------
158 | |
159 | | The following language lines are used to swap our attribute placeholder
160 | | with something more reader friendly such as "E-Mail Address" instead
161 | | of "email". This simply helps us make our message more expressive.
162 | |
163 | */
164 |
165 | 'attributes' => [],
166 |
167 | ];
168 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "mix",
6 | "watch": "mix watch",
7 | "watch-poll": "mix watch -- --watch-options-poll=1000",
8 | "hot": "mix watch --hot",
9 | "prod": "npm run production",
10 | "production": "mix --production"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.25",
14 | "laravel-mix": "^6.0.6",
15 | "lodash": "^4.17.19",
16 | "postcss": "^8.1.14"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/phpstan.neon:
--------------------------------------------------------------------------------
1 | parameters:
2 |
3 | # The level 9 is the highest level
4 | level: 8
5 |
6 | reportMaybesInPropertyPhpDocTypes: false
7 | checkMissingIterableValueType: false
8 | checkOctaneCompatibility: false
9 |
10 | paths:
11 | - app
12 |
13 | excludePaths:
14 | # - app/Nova/*
15 | # - app/Http/Livewire/*
16 |
17 | ignoreErrors:
18 | - '#is not allowed to extend.#'
19 | - '#Short ternary operator is not allowed. Use null coalesce operator if applicable or consider using long ternary.#'
20 | - '#has a nullable return type declaration.#'
21 | - '#has parameter \$[a-zA-Z]+ with null as default value.#'
22 | # - '#Dynamic call to static method.#'
23 | # - '#has parameter \$[a-zA-Z]+ with default value.#'
24 | # - '#has parameter \$[a-zA-Z]+ with a nullable type declaration.#'
25 | # - '#Parameter \#[0-9] \$column of method Illuminate\\Database\\Eloquent\\Builder\\:\:whereIn\(\) expects string, Illuminate\\Database\\Query\\Expression given.#'
26 | # - '#is protected, but since the containing class is final, it can be private.#'
27 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 | ./tests/Analysis
11 |
12 |
13 | ./tests/Feature
14 |
15 |
16 |
17 |
18 | ./app
19 | ./routes
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Send Requests To Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Treblle/laravel-api-boilerplate/a12603b8a5d236467b8565cc95d9c69c80dff5e5/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class);
50 |
51 | $response = $kernel->handle(
52 | $request = Request::capture()
53 | )->send();
54 |
55 | $kernel->terminate($request, $response);
56 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/rector-bootstrap.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class);
10 |
11 | $kernel->handle($request = Request::capture());
12 |
--------------------------------------------------------------------------------
/rector.php:
--------------------------------------------------------------------------------
1 | parameters();
15 | $services = $containerConfigurator->services();
16 |
17 | $parameters->set(Option::BOOTSTRAP_FILES, [
18 | $dir.'/rector-bootstrap.php',
19 | ]);
20 |
21 | $parameters->set(Option::PATHS, [
22 | $dir.'/app',
23 | ]);
24 |
25 | $parameters->set(Option::SKIP, [
26 | $dir.'/app/Http/Livewire',
27 | ]);
28 |
29 | if (file_exists($neon = $dir.'/phpstan.neon')) {
30 | $parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, $neon);
31 | }
32 |
33 | $parameters->set(Option::AUTO_IMPORT_NAMES, true);
34 | $parameters->set(Option::IMPORT_SHORT_CLASSES, true);
35 | $parameters->set(Option::IMPORT_DOC_BLOCKS, false);
36 |
37 | $containerConfigurator->import(LevelSetList::UP_TO_PHP_81);
38 |
39 | $containerConfigurator->import(SetList::PRIVATIZATION);
40 | $services->remove(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
41 | $services->remove(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
42 | $services->remove(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
43 |
44 | $containerConfigurator->import(SetList::EARLY_RETURN);
45 |
46 | $containerConfigurator->import(SetList::CODING_STYLE);
47 | $services->remove(\Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class);
48 | $services->remove(\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class);
49 | $services->remove(\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class);
50 | $services->remove(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class);
51 |
52 | $containerConfigurator->import(LaravelSetList::LARAVEL_80);
53 | $containerConfigurator->import(LaravelSetList::LARAVEL_CODE_QUALITY);
54 | $containerConfigurator->import(LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL);
55 | };
56 |
--------------------------------------------------------------------------------
/routes/api.php:
--------------------------------------------------------------------------------
1 | group(function () {
21 | Route::prefix('users')->group(function () {
22 | Route::get('/', UsersIndexController::class)->name('users.index');
23 | Route::get('/{user}', UsersShowController::class)->name('users.show');
24 | Route::match(['put', 'patch'], '/{user}', UsersUpdateController::class)->name('users.update');
25 | Route::delete('/{user}', UsersDestroyController::class)->name('users.destroy');
26 | });
27 |
28 | Route::prefix('posts')->group(function () {
29 | Route::get('/', PostsIndexController::class)->name('posts.index');
30 | Route::post('/', PostsStoreController::class)->name('posts.store');
31 | Route::get('/{post}', PostsShowController::class)->name('posts.show');
32 | Route::match(['put', 'patch'], '/{post}', PostsUpdateController::class)->name('posts.update');
33 | Route::delete('/{post}', PostsDestroyController::class)->name('posts.destroy');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/routes/channels.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
20 | });
21 |
--------------------------------------------------------------------------------
/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
21 | })->purpose('Display an inspiring quote');
22 |
--------------------------------------------------------------------------------
/routes/web.php:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
20 | // Response::HTTP_NOT_FOUND
21 | // );
22 |
23 | {{ model }}->delete();
24 |
25 | return response()->json([], Response::HTTP_NO_CONTENT);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/stubs/controller.index.stub:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
19 | // Response::HTTP_NOT_FOUND
20 | // );
21 |
22 | //
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/stubs/controller.show.stub:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
20 | // Response::HTTP_NOT_FOUND
21 | // );
22 |
23 | //
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/stubs/controller.store.stub:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
18 | // Response::HTTP_NOT_FOUND
19 | // );
20 |
21 | //
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/stubs/controller.update.stub:
--------------------------------------------------------------------------------
1 | greaterThanOrEqualsTo(Version::v1_0),
19 | // Response::HTTP_NOT_FOUND
20 | // );
21 |
22 | //
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/stubs/migration.create.stub:
--------------------------------------------------------------------------------
1 | id();
20 | $table->uuid()->index();
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | *
28 | * @return void
29 | */
30 | public function down()
31 | {
32 | Schema::dropIfExists('{{ table }}');
33 | }
34 | };
35 |
--------------------------------------------------------------------------------
/stubs/model.stub:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
10 |
11 | actingAs()
12 | // use the correct verb for your use case. For example `deleteJson($endpoint)`
13 | ->getJson($endpoint)
14 | ->assertStatus(Response::HTTP_NOT_FOUND);
15 | });
16 |
17 | it('returns a successful status code', function (): void {
18 | $endpoint = routeVersioned('{{ change with the resource name }}', ['{{ change with the param name }}' => 1], Version::v1_0);
19 |
20 | actingAs()
21 | // use the correct verb for your use case. For example `deleteJson($endpoint)`
22 | ->getJson($endpoint)
23 | ->assertStatus(Response::HTTP_OK);
24 | });
25 |
--------------------------------------------------------------------------------
/stubs/request.stub:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
21 |
22 | return $app;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Feature/Console/Commands/UserCreateCommandTest.php:
--------------------------------------------------------------------------------
1 | '',
14 | '--email' => 'john.doe@example.com',
15 | '--password' => 'password',
16 | ])
17 | ->expectsOutput(trans('validation.required', ['attribute' => 'name']))
18 | ->assertExitCode(1);
19 |
20 | assertDatabaseMissing(User::class, [
21 | 'email' => 'john.doe@example.com',
22 | ]);
23 | });
24 |
25 | it('raise an error if name is too long', function (): void {
26 | artisan('user:create', [
27 | '--name' => Str::random(256),
28 | '--email' => 'john.doe@example.com',
29 | '--password' => 'password',
30 | ])
31 | ->expectsOutput(trans('validation.max.string', ['attribute' => 'name', 'max' => '255']))
32 | ->assertExitCode(1);
33 |
34 | assertDatabaseMissing(User::class, [
35 | 'email' => 'john.doe@example.com',
36 | ]);
37 | });
38 |
39 | it('raise an error if email is not present', function (): void {
40 | artisan('user:create', [
41 | '--name' => 'John Doe',
42 | '--email' => '',
43 | '--password' => 'password',
44 | ])
45 | ->expectsOutput(trans('validation.required', ['attribute' => 'email']))
46 | ->assertExitCode(1);
47 |
48 | assertDatabaseMissing(User::class, [
49 | 'name' => 'John Doe',
50 | ]);
51 | });
52 |
53 | it('raise an error if email is not a valid email address', function (): void {
54 | artisan('user:create', [
55 | '--name' => 'John Doe',
56 | '--email' => 'not a valid email address',
57 | '--password' => 'password',
58 | ])
59 | ->expectsOutput(trans('validation.email', ['attribute' => 'email']))
60 | ->assertExitCode(1);
61 |
62 | assertDatabaseMissing(User::class, [
63 | 'name' => 'John Doe',
64 | ]);
65 | });
66 |
67 | it('raise an error if email is too long', function (): void {
68 | artisan('user:create', [
69 | '--name' => 'John Doe',
70 | '--email' => Str::random(244).'@example.com',
71 | '--password' => 'password',
72 | ])
73 | ->expectsOutput(trans('validation.max.string', ['attribute' => 'email', 'max' => '255']))
74 | ->assertExitCode(1);
75 |
76 | assertDatabaseMissing(User::class, [
77 | 'name' => 'John Doe',
78 | ]);
79 | });
80 |
81 | it('raise an error if password is not present', function (): void {
82 | artisan('user:create', [
83 | '--name' => 'John Doe',
84 | '--email' => Str::random(245).'@example.com',
85 | '--password' => '',
86 | ])
87 | ->expectsOutput(trans('validation.required', ['attribute' => 'password']))
88 | ->assertExitCode(1);
89 |
90 | assertDatabaseMissing(User::class, [
91 | 'name' => 'John Doe',
92 | ]);
93 | });
94 |
95 | it('raise an error if password is less than 6 characters', function (): void {
96 | artisan('user:create', [
97 | '--name' => 'John Doe',
98 | '--email' => Str::random(245).'@example.com',
99 | '--password' => 'passw',
100 | ])
101 | ->expectsOutput(trans('validation.min.string', ['attribute' => 'password', 'min' => '6']))
102 | ->assertExitCode(1);
103 |
104 | assertDatabaseMissing(User::class, [
105 | 'name' => 'John Doe',
106 | ]);
107 | });
108 |
109 | it('creates a new user with data passed inline', function (): void {
110 | artisan('user:create', [
111 | '--name' => 'John Doe',
112 | '--email' => 'john.doe@example.com',
113 | '--password' => 'password',
114 | ])
115 | ->expectsOutput(trans('artisan.create_user.alerts.confirmation'))
116 | ->expectsTable(['Name', 'Email', 'Password'], [
117 | ['John Doe', 'john.doe@example.com', 'password'],
118 | ])
119 | ->assertExitCode(0);
120 |
121 | assertDatabaseHas(User::class, [
122 | 'name' => 'John Doe',
123 | 'email' => 'john.doe@example.com',
124 | ]);
125 | });
126 |
127 | it('creates a new user', function (): void {
128 | artisan('user:create')
129 | ->expectsOutput(trans('artisan.create_user.description'))
130 | ->expectsConfirmation(trans('artisan.create_user.dialogs.confirm_before_executing'), 'yes')
131 | ->expectsQuestion(trans('artisan.create_user.questions.name'), 'John Doe')
132 | ->expectsQuestion(trans('artisan.create_user.questions.email'), 'john.doe@example.com')
133 | ->expectsQuestion(trans('artisan.create_user.questions.password'), 'password')
134 | ->expectsOutput(trans('artisan.create_user.alerts.confirmation'))
135 | ->expectsTable(['Name', 'Email', 'Password'], [
136 | ['John Doe', 'john.doe@example.com', 'password'],
137 | ])
138 | ->assertExitCode(0);
139 |
140 | assertDatabaseHas(User::class, [
141 | 'name' => 'John Doe',
142 | 'email' => 'john.doe@example.com',
143 | ]);
144 | });
145 |
--------------------------------------------------------------------------------
/tests/Feature/Enums/VersionTest.php:
--------------------------------------------------------------------------------
1 | satisfies('^1.0'))->toBeTrue();
9 | expect(Version::v1_1->satisfies('^1.0'))->toBeTrue();
10 | expect(Version::v1_0->satisfies('^1.1'))->toBeFalse();
11 | expect(Version::v1_1->satisfies('1.0'))->toBeFalse();
12 | expect(Version::v1_1->satisfies('^1.1'))->toBeTrue();
13 | expect(Version::v2_0->satisfies('^1.1'))->toBeFalse();
14 | expect(Version::v2_0->satisfies('^2.0'))->toBeTrue();
15 | });
16 |
17 | it('checks if the version is greater than a given one', function (): void {
18 | expect(Version::v1_1->greaterThan(Version::v1_0))->toBeTrue();
19 | expect(Version::v1_0->greaterThan(Version::v1_0))->toBeFalse();
20 | expect(Version::v1_0->greaterThan(Version::v1_1))->toBeFalse();
21 | });
22 |
23 | it('checks if the version is greater than or equals to a given one', function (): void {
24 | expect(Version::v1_0->greaterThanOrEqualsTo(Version::v1_0))->toBeTrue();
25 | expect(Version::v1_0->greaterThanOrEqualsTo(Version::v1_1))->toBeFalse();
26 | });
27 |
28 | it('checks if the version is less than a given one', function (): void {
29 | expect(Version::v1_0->lessThan(Version::v1_1))->toBeTrue();
30 | expect(Version::v1_0->lessThan(Version::v1_0))->toBeFalse();
31 | expect(Version::v1_1->lessThan(Version::v1_0))->toBeFalse();
32 | });
33 |
34 | it('checks if the version is less than or equals to a given one', function (): void {
35 | expect(Version::v1_0->lessThanOrEqualsTo(Version::v1_0))->toBeTrue();
36 | expect(Version::v1_1->lessThanOrEqualsTo(Version::v1_0))->toBeFalse();
37 | });
38 |
39 | it('checks if the version is equals to a given one', function (): void {
40 | expect(Version::v1_0->equalsTo(Version::v1_0))->toBeTrue();
41 | expect(Version::v1_0->equalsTo(Version::v1_1))->toBeFalse();
42 | });
43 |
44 | it('checks if the version is not equals to a given one', function (): void {
45 | expect(Version::v1_0->notEqualsTo(Version::v1_0))->toBeFalse();
46 | expect(Version::v1_0->notEqualsTo(Version::v1_1))->toBeTrue();
47 | });
48 |
--------------------------------------------------------------------------------
/tests/Feature/HomePageTest.php:
--------------------------------------------------------------------------------
1 | get('/')->assertSuccessful();
7 | });
8 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/AuthTokenTest.php:
--------------------------------------------------------------------------------
1 | create();
14 |
15 | postJson(url('api/auth/token'), [
16 | 'password' => $user->password,
17 | 'token_name' => 'acme 1',
18 | ])
19 | ->assertJsonValidationErrorFor('email')
20 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
21 | });
22 |
23 | it('fails if email does not exist', function (): void {
24 | $user = User::factory()->create();
25 |
26 | postJson(url('api/auth/token'), [
27 | 'email' => 'foo@example.com',
28 | 'password' => $user->password,
29 | 'token_name' => 'acme 1',
30 | ])
31 | ->assertJsonValidationErrorFor('email')
32 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
33 | });
34 |
35 | it('fails if email is not a valid email address', function (): void {
36 | $user = User::factory()->create();
37 |
38 | postJson(url('api/auth/token'), [
39 | 'email' => 'not a valid email address',
40 | 'password' => $user->password,
41 | 'token_name' => 'acme 1',
42 | ])
43 | ->assertJsonValidationErrorFor('email')
44 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
45 | });
46 |
47 | it('fails if password is not provided', function (): void {
48 | $user = User::factory()->create();
49 |
50 | postJson(url('api/auth/token'), [
51 | 'email' => $user->email,
52 | 'token_name' => 'acme 1',
53 | ])
54 | ->assertJsonValidationErrorFor('password')
55 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
56 | });
57 |
58 | it('fails if token name is not provided', function (): void {
59 | $user = User::factory()->create();
60 |
61 | postJson(url('api/auth/token'), [
62 | 'email' => $user->email,
63 | 'password' => $user->password,
64 | ])
65 | ->assertJsonValidationErrorFor('token_name')
66 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
67 | });
68 |
69 | it('fails if token name does not contains only alphanumeric characters', function (): void {
70 | $user = User::factory()->create();
71 |
72 | postJson(url('api/auth/token'), [
73 | 'email' => $user->email,
74 | 'password' => $user->password,
75 | 'token_name' => 'acme 1',
76 | ])
77 | ->assertJsonValidationErrorFor('token_name')
78 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
79 | });
80 |
81 | it('fails if token name is too long', function (): void {
82 | $user = User::factory()->create();
83 |
84 | postJson(url('api/auth/token'), [
85 | 'email' => $user->email,
86 | 'password' => $user->password,
87 | 'token_name' => Str::random(51),
88 | ])
89 | ->assertJsonValidationErrorFor('token_name')
90 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
91 | });
92 |
93 | it('creates a new token for the given user', function (): void {
94 | $user = User::factory()->create();
95 |
96 | assertDatabaseMissing('personal_access_tokens', [
97 | 'name' => 'Acme001',
98 | ]);
99 |
100 | postJson(url('api/auth/token'), [
101 | 'email' => $user->email,
102 | 'password' => 'password',
103 | 'token_name' => 'Acme001',
104 | ])
105 | ->assertStatus(Response::HTTP_CREATED)
106 | ->assertJsonStructure(['token']);
107 |
108 | assertDatabaseHas('personal_access_tokens', [
109 | 'name' => 'Acme001',
110 | ]);
111 | });
112 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Posts/PostsDestroyControllerTest.php:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
11 |
12 | actingAs()
13 | ->deleteJson($endpoint)
14 | ->assertStatus(Response::HTTP_NOT_FOUND);
15 | });
16 |
17 | it('returns a successful status code', function (): void {
18 | $post = Post::factory()->create();
19 | $endpoint = routeVersioned('posts', ['post' => $post], Version::v1_0);
20 |
21 | actingAs()
22 | ->deleteJson($endpoint)
23 | ->assertStatus(Response::HTTP_NO_CONTENT);
24 | });
25 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Posts/PostsIndexControllerTest.php:
--------------------------------------------------------------------------------
1 | getJson($endpoint)
14 | ->assertStatus(Response::HTTP_NOT_FOUND);
15 | });
16 |
17 | it('returns a successful status code', function (): void {
18 | Post::factory(3)->create();
19 | $endpoint = routeVersioned('posts', [], Version::v1_0);
20 |
21 | actingAs()
22 | ->getJson($endpoint)
23 | ->assertStatus(Response::HTTP_OK)
24 | ->assertJsonStructure([
25 | 'data',
26 | 'links',
27 | 'meta',
28 | ]);
29 | });
30 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Posts/PostsShowControllerTest.php:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
11 |
12 | actingAs()
13 | ->getJson($endpoint)
14 | ->assertStatus(Response::HTTP_NOT_FOUND);
15 | });
16 |
17 | it('shows the given post', function (): void {
18 | $post = Post::factory()->create();
19 | $endpoint = routeVersioned('posts', ['post' => $post], Version::v1_0);
20 |
21 | actingAs()
22 | ->getJson($endpoint)
23 | ->assertStatus(Response::HTTP_OK)
24 | ->assertJsonFragment([
25 | 'data' => [
26 | 'uuid' => $post->uuid,
27 | 'title' => $post->title,
28 | 'body' => $post->content,
29 | 'created_at' => $post->created_at,
30 | 'updated_at' => $post->updated_at,
31 | 'author' => [
32 | 'uuid' => $post->author->uuid,
33 | 'name' => $post->author->name,
34 | 'email' => $post->author->email,
35 | 'created_at' => $post->author->created_at,
36 | 'updated_at' => $post->author->updated_at,
37 | ],
38 | ],
39 | ]);
40 | });
41 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Posts/PostsStoreControllerTest.php:
--------------------------------------------------------------------------------
1 | postJson($endpoint)
14 | ->assertStatus(Response::HTTP_NOT_FOUND);
15 | });
16 |
17 | it('raises an error if title is not provided', function (): void {
18 | $endpoint = routeVersioned('posts', [], Version::v1_0);
19 |
20 | actingAs()
21 | ->postJson($endpoint, [
22 | 'content' => 'the post content',
23 | ])
24 | ->assertJsonValidationErrorFor('title')
25 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
26 | });
27 |
28 | it('raises an error if content is not provided', function (): void {
29 | $endpoint = routeVersioned('posts', [], Version::v1_0);
30 |
31 | actingAs()
32 | ->postJson($endpoint, [
33 | 'title' => 'the post title',
34 | ])
35 | ->assertJsonValidationErrorFor('content')
36 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
37 | });
38 |
39 | it('creates a new post', function (): void {
40 | $endpoint = routeVersioned('posts', [], Version::v1_0);
41 |
42 | actingAs()
43 | ->postJson($endpoint, [
44 | 'title' => 'The post title',
45 | 'content' => 'The post content',
46 | ])
47 | ->assertSuccessful();
48 |
49 | $this->assertDatabaseHas(Post::class, [
50 | 'title' => 'The post title',
51 | 'content' => 'The post content',
52 | ]);
53 | });
54 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Posts/PostsUpdateControllerTest.php:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
11 |
12 | actingAs()
13 | ->putJson($endpoint)
14 | ->assertStatus(Response::HTTP_NOT_FOUND);
15 | });
16 |
17 | it('raises an error if title is not provided', function (): void {
18 | $post = Post::factory()->create();
19 | $endpoint = routeVersioned('posts', ['post' => $post], Version::v1_0);
20 |
21 | actingAs()
22 | ->putJson($endpoint, [
23 | 'content' => 'the post content',
24 | ])
25 | ->assertJsonValidationErrorFor('title')
26 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
27 | });
28 |
29 | it('raises an error if content is not provided', function (): void {
30 | $post = Post::factory()->create();
31 | $endpoint = routeVersioned('posts', ['post' => $post], Version::v1_0);
32 |
33 | actingAs()
34 | ->putJson($endpoint, [
35 | 'title' => 'the post title',
36 | ])
37 | ->assertJsonValidationErrorFor('content')
38 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
39 | });
40 |
41 | it('updates the given post', function (): void {
42 | $post = Post::factory()->create();
43 | $endpoint = routeVersioned('posts', ['post' => $post], Version::v1_0);
44 |
45 | actingAs()
46 | ->putJson($endpoint, [
47 | 'title' => 'The post title',
48 | 'content' => 'The post content',
49 | ])
50 | ->assertSuccessful();
51 |
52 | $this->assertDatabaseMissing(Post::class, [
53 | 'title' => $post->title,
54 | 'content' => $post->content,
55 | ]);
56 |
57 | $this->assertDatabaseHas(Post::class, [
58 | 'id' => $post->id,
59 | 'title' => 'The post title',
60 | 'content' => 'The post content',
61 | ]);
62 | });
63 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Users/UsersDestroyControllerTest.php:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
11 |
12 | actingAs()
13 | ->deleteJson($endpoint)
14 | ->assertNotFound();
15 | });
16 |
17 | it('destroys the given user', function (): void {
18 | $user = User::factory()->create();
19 | $endpoint = routeVersioned('users', ['user' => $user->uuid], Version::v1_0);
20 |
21 | actingAs()
22 | ->deleteJson($endpoint)
23 | ->assertStatus(Response::HTTP_NO_CONTENT);
24 |
25 | $this->assertDatabaseMissing(User::class, [
26 | 'uuid' => $user->uuid,
27 | ]);
28 | });
29 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Users/UsersIndexControllerTest.php:
--------------------------------------------------------------------------------
1 | getJson($endpoint)
13 | ->assertNotFound();
14 | });
15 |
16 | it('gets a collection of users', function (): void {
17 | User::factory(3)->create();
18 | $endpoint = routeVersioned('users', [], Version::v1_0);
19 |
20 | actingAs()
21 | ->getJson($endpoint)
22 | ->assertSuccessful()
23 | ->assertJsonStructure([
24 | 'data',
25 | 'links',
26 | 'meta',
27 | ]);
28 | });
29 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Users/UsersShowControllerTest.php:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
10 |
11 | actingAs()
12 | ->getJson($endpoint)
13 | ->assertNotFound();
14 | });
15 |
16 | it('shows the given user', function (): void {
17 | $user = User::factory()->create();
18 | $endpoint = routeVersioned('users', ['user' => $user], Version::v1_0);
19 |
20 | actingAs()
21 | ->getJson($endpoint)
22 | ->assertSuccessful();
23 | });
24 |
--------------------------------------------------------------------------------
/tests/Feature/Http/Controllers/Api/v1_0/Users/UsersUpdateControllerTest.php:
--------------------------------------------------------------------------------
1 | 1], 'v0.1');
11 |
12 | actingAs()
13 | ->putJson($endpoint)
14 | ->assertNotFound();
15 | });
16 |
17 | it('raises an error if name is not provided', function (): void {
18 | $user = User::factory()->create();
19 | $endpoint = routeVersioned('users', ['user' => $user], Version::v1_0);
20 |
21 | actingAs()
22 | ->putJson($endpoint, [
23 | 'email' => 'john@api-world.com',
24 | ])
25 | ->assertJsonValidationErrorFor('name')
26 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
27 | });
28 |
29 | it('raises an error if name is too long', function (): void {
30 | $user = User::factory()->create();
31 | $endpoint = routeVersioned('users', ['user' => $user], Version::v1_0);
32 |
33 | actingAs()
34 | ->putJson($endpoint, [
35 | 'name' => Str::random(256),
36 | ])
37 | ->assertJsonValidationErrorFor('name')
38 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
39 | });
40 |
41 | it('raises an error if email has an invalid format', function (): void {
42 | $user = User::factory()->create();
43 | $endpoint = routeVersioned('users', ['user' => $user], Version::v1_0);
44 |
45 | actingAs()
46 | ->putJson($endpoint, [
47 | 'name' => 'John Doe',
48 | ])
49 | ->assertJsonValidationErrorFor('email')
50 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
51 | });
52 |
53 | it('raises an error if email is not in the correct format', function (): void {
54 | $user = User::factory()->create();
55 | $endpoint = routeVersioned('users', ['user' => $user], Version::v1_0);
56 |
57 | actingAs()
58 | ->putJson($endpoint, [
59 | 'email' => 'this is not an email',
60 | ])
61 | ->assertJsonValidationErrorFor('email')
62 | ->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
63 | });
64 |
65 | it('updates the given user', function (): void {
66 | $user = User::factory()->create();
67 | $endpoint = routeVersioned('users', ['user' => $user], Version::v1_0);
68 |
69 | actingAs()
70 | ->putJson($endpoint, [
71 | 'name' => 'John Doe',
72 | 'email' => 'john@api-world.com',
73 | ])
74 | ->assertSuccessful();
75 |
76 | $this->assertDatabaseMissing(User::class, [
77 | 'name' => $user->name,
78 | 'email' => $user->email,
79 | ]);
80 |
81 | $this->assertDatabaseHas(User::class, [
82 | 'id' => $user->id,
83 | 'name' => 'John Doe',
84 | 'email' => 'john@api-world.com',
85 | ]);
86 | });
87 |
--------------------------------------------------------------------------------
/tests/Feature/Models/PostTest.php:
--------------------------------------------------------------------------------
1 | create();
10 |
11 | expect($post->author)->toBeInstanceOf(User::class);
12 | });
13 |
--------------------------------------------------------------------------------
/tests/Feature/Models/UserTest.php:
--------------------------------------------------------------------------------
1 | create();
11 | $ownedPosts = Post::factory(3)->create(['user_id' => $user->id]);
12 | $otherPosts = Post::factory(3)->create();
13 |
14 | expect($user->posts)->toBeInstanceOf(Collection::class);
15 | expect($user->posts)->toHaveCount(3);
16 | expect($user->posts[0]->id)->toBe($ownedPosts[0]->id);
17 | expect($user->posts[1]->id)->toBe($ownedPosts[1]->id);
18 | expect($user->posts[2]->id)->toBe($ownedPosts[2]->id);
19 | expect($user->posts[0]->id)->not()->toBe($otherPosts[0]->id);
20 | expect($user->posts[1]->id)->not()->toBe($otherPosts[1]->id);
21 | expect($user->posts[2]->id)->not()->toBe($otherPosts[2]->id);
22 | });
23 |
--------------------------------------------------------------------------------
/tests/Helpers.php:
--------------------------------------------------------------------------------
1 | create();
25 | }
26 |
27 | Sanctum::actingAs($user, $abilities);
28 |
29 | return test();
30 | }
31 |
32 | function logout(): void
33 | {
34 | auth()->logout();
35 | }
36 |
37 | function routeVersioned(string $name, array $attributes = [], Version|string $version = 'v1.0'): string
38 | {
39 | if (is_a($version, Version::class)) {
40 | $version = $version->value;
41 | }
42 |
43 | return url('api', [
44 | 'version' => $version,
45 | 'name' => $name,
46 | ] + $attributes);
47 | }
48 |
--------------------------------------------------------------------------------
/tests/Pest.php:
--------------------------------------------------------------------------------
1 | in('Analysis');
20 | uses(TestCase::class, RefreshDatabase::class)->in('Feature');
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Expectations
25 | |--------------------------------------------------------------------------
26 | |
27 | | When you're writing tests, you often need to check that values meet certain conditions. The
28 | | "expect()" function gives you access to a set of "expectations" methods that you can use
29 | | to assert different things. Of course, you may extend the Expectation API at any time.
30 | |
31 | */
32 |
33 | expect()->extend('toBeOne', function () {
34 | return $this->toBe(1);
35 | });
36 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 |