Skip to content

Commit 2a1fa5f

Browse files
authored
Use case: Laravel (#42)
1 parent a576e14 commit 2a1fa5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2415
-1
lines changed

.github/workflows/cases.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
- name: Run case
3131
run: |
3232
cd cases/incompatible-signature
33-
composer --version
3433
composer update --no-interaction --no-progress ${{ matrix.composer-tweak }}
3534
3635
case-symfony:
@@ -56,3 +55,28 @@ jobs:
5655
cd cases/symfony
5756
composer install --no-interaction --no-progress
5857
php test.php
58+
59+
case-laravel:
60+
runs-on: ubuntu-latest
61+
strategy:
62+
matrix:
63+
php-version:
64+
- "8.2"
65+
- "8.4"
66+
composer-version:
67+
- "v2.4.0"
68+
- "v2"
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v4
72+
- name: Install PHP
73+
uses: shivammathur/setup-php@v2
74+
with:
75+
php-version: ${{ matrix.php-version }}
76+
ini-values: memory_limit=-1
77+
tools: composer:${{ matrix.composer-version }}
78+
- name: Run case
79+
run: |
80+
cd cases/laravel
81+
composer install --no-interaction --no-progress
82+
php test.php

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ Use cases are available to test the plugin in real conditions:
222222

223223
- [Symfony](cases/symfony) A Symfony application, created with `symfony new`.
224224

225+
- [Laravel](cases/symfony) A Laravel application, created with `laravel new`.
226+
225227

226228

227229
## Frequently Asked Questions

cases/laravel/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

cases/laravel/.env.example

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
APP_LOCALE=en
8+
APP_FALLBACK_LOCALE=en
9+
APP_FAKER_LOCALE=en_US
10+
11+
APP_MAINTENANCE_DRIVER=file
12+
# APP_MAINTENANCE_STORE=database
13+
14+
PHP_CLI_SERVER_WORKERS=4
15+
16+
BCRYPT_ROUNDS=12
17+
18+
LOG_CHANNEL=stack
19+
LOG_STACK=single
20+
LOG_DEPRECATIONS_CHANNEL=null
21+
LOG_LEVEL=debug
22+
23+
DB_CONNECTION=sqlite
24+
# DB_HOST=127.0.0.1
25+
# DB_PORT=3306
26+
# DB_DATABASE=laravel
27+
# DB_USERNAME=root
28+
# DB_PASSWORD=
29+
30+
SESSION_DRIVER=database
31+
SESSION_LIFETIME=120
32+
SESSION_ENCRYPT=false
33+
SESSION_PATH=/
34+
SESSION_DOMAIN=null
35+
36+
BROADCAST_CONNECTION=log
37+
FILESYSTEM_DISK=local
38+
QUEUE_CONNECTION=database
39+
40+
CACHE_STORE=database
41+
# CACHE_PREFIX=
42+
43+
MEMCACHED_HOST=127.0.0.1
44+
45+
REDIS_CLIENT=phpredis
46+
REDIS_HOST=127.0.0.1
47+
REDIS_PASSWORD=null
48+
REDIS_PORT=6379
49+
50+
MAIL_MAILER=log
51+
MAIL_SCHEME=null
52+
MAIL_HOST=127.0.0.1
53+
MAIL_PORT=2525
54+
MAIL_USERNAME=null
55+
MAIL_PASSWORD=null
56+
MAIL_FROM_ADDRESS="hello@example.com"
57+
MAIL_FROM_NAME="${APP_NAME}"
58+
59+
AWS_ACCESS_KEY_ID=
60+
AWS_SECRET_ACCESS_KEY=
61+
AWS_DEFAULT_REGION=us-east-1
62+
AWS_BUCKET=
63+
AWS_USE_PATH_STYLE_ENDPOINT=false
64+
65+
VITE_APP_NAME="${APP_NAME}"

cases/laravel/.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
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+
.styleci.yml export-ignore

cases/laravel/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*.log
2+
.DS_Store
3+
.env
4+
.env.backup
5+
.env.production
6+
.phpactor.json
7+
.phpunit.result.cache
8+
/.fleet
9+
/.idea
10+
/.nova
11+
/.phpunit.cache
12+
/.vscode
13+
/.zed
14+
/auth.json
15+
/node_modules
16+
/public/build
17+
/public/hot
18+
/public/storage
19+
/storage/*.key
20+
/storage/pail
21+
/vendor
22+
Homestead.json
23+
Homestead.yaml
24+
Thumbs.db

cases/laravel/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ARG PHP_TAG=8.0-cli-buster
2+
FROM php:${PHP_TAG}
3+
4+
RUN <<-EOF
5+
apt-get update
6+
apt-get install -y autoconf pkg-config
7+
pecl channel-update pecl.php.net
8+
pecl install xdebug
9+
docker-php-ext-enable opcache xdebug
10+
EOF
11+
12+
RUN <<-EOF
13+
cat <<-SHELL >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
14+
xdebug.client_host=host.docker.internal
15+
xdebug.mode=develop
16+
xdebug.start_with_request=yes
17+
SHELL
18+
19+
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
20+
display_errors=On
21+
error_reporting=E_ALL
22+
date.timezone=UTC
23+
SHELL
24+
EOF
25+
26+
ENV COMPOSER_ALLOW_SUPERUSER 1
27+
28+
RUN <<-EOF
29+
apt-get update
30+
apt-get install unzip
31+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
32+
php composer-setup.php --version=2.4.0
33+
php -r "unlink('composer-setup.php');"
34+
mv composer.phar /usr/local/bin/composer
35+
cat <<-SHELL >> /root/.bashrc
36+
export PATH="$HOME/.composer/vendor/bin:$PATH"
37+
SHELL
38+
EOF

cases/laravel/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# do not edit the following lines
2+
3+
vendor:
4+
@composer install --prefer-lowest
5+
6+
.PHONY: test-container
7+
test-container: test-container82
8+
9+
.PHONY: test-container82
10+
test-container82:
11+
@-docker compose run --rm app82 bash
12+
@docker compose down -v
13+
14+
.PHONY: test-container84
15+
test-container84:
16+
@-docker compose run --rm app84 bash
17+
@docker compose down -v

cases/laravel/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Use case: Laravel
2+
3+
Demonstrates the usage of [olvlvl/composer-attribute-collector][] with a
4+
[Laravel](https://laravel.com/) application. The use case is tested with Composer v2.4.0 and the
5+
latest version, running with PHP 8.2 and 8.4.
6+
7+
After requiring `olvlvl/composer-attribute-collector`, executing `php test.php` should yield an
8+
output as follows, or throw an exception if the collection didn't succeed.
9+
10+
```php
11+
/app/test.php:15:
12+
array(2) {
13+
[0] =>
14+
class olvlvl\ComposerAttributeCollector\TargetClass#6 (2) {
15+
public object $attribute =>
16+
class App\Attributes\SampleAttribute#5 (0) {
17+
}
18+
public string $name =>
19+
string(15) "App\Models\User"
20+
}
21+
[1] =>
22+
class olvlvl\ComposerAttributeCollector\TargetClass#8 (2) {
23+
public object $attribute =>
24+
class App\Attributes\SampleAttribute#7 (0) {
25+
}
26+
public string $name =>
27+
string(32) "App\Providers\AppServiceProvider"
28+
}
29+
}
30+
```
31+
32+
33+
34+
[olvlvl/composer-attribute-collector]: https://github.com/olvlvl/composer-attribute-collector
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace App\Attributes;
4+
5+
#[\Attribute(\Attribute::TARGET_CLASS)]
6+
class SampleAttribute
7+
{
8+
}

0 commit comments

Comments
 (0)