Skip to content

Commit 04758f6

Browse files
committed
feat: initial commit
0 parents  commit 04758f6

15 files changed

+935
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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}]
15+
indent_size = 2

.gitattributes

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.github export-ignore
2+
/tests export-ignore
3+
.editorconfig export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
.php-cs-fixer.dist.php export-ignore
7+
grumphp.yml export-ignore
8+
phpstan.neon export-ignore
9+
phpunit.xml.dist export-ignore

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
/composer.lock
3+
.phpunit.result.cache
4+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of Ymir Laravel Bridge.
5+
6+
(c) Carl Alexander <[email protected]>
7+
8+
For the full copyright and license information, please view the LICENSE
9+
file that was distributed with this source code.
10+
EOF;
11+
12+
$finder = PhpCsFixer\Finder::create()
13+
->in([
14+
__DIR__ . '/src',
15+
__DIR__ . '/tests',
16+
])
17+
;
18+
19+
$config = new PhpCsFixer\Config();
20+
$config
21+
->setRiskyAllowed(true)
22+
->setRules([
23+
'@Symfony' => true,
24+
'@Symfony:risky' => true,
25+
'align_multiline_comment' => true,
26+
'array_syntax' => ['syntax' => 'short'],
27+
'blank_line_before_statement' => true,
28+
'combine_consecutive_issets' => true,
29+
'combine_consecutive_unsets' => true,
30+
'declare_strict_types' => true,
31+
// one should use PHPUnit methods to set up expected exception instead of annotations
32+
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp']],
33+
'explicit_string_variable' => true,
34+
'header_comment' => ['header' => $header],
35+
'heredoc_to_nowdoc' => true,
36+
'list_syntax' => ['syntax' => 'long'],
37+
'method_chaining_indentation' => false,
38+
'native_function_invocation' => false,
39+
'native_constant_invocation' => false,
40+
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
41+
'no_null_property_initialization' => true,
42+
'echo_tag_syntax' => ['format' => 'long'],
43+
'no_superfluous_phpdoc_tags' => ['allow_mixed' => false],
44+
'no_unneeded_curly_braces' => true,
45+
'no_unneeded_final_method' => true,
46+
'no_unreachable_default_argument_value' => true,
47+
'no_useless_else' => true,
48+
'no_useless_return' => true,
49+
'ordered_class_elements' => [
50+
'order' => [
51+
'use_trait',
52+
'constant_public',
53+
'constant_protected',
54+
'constant_private',
55+
'property_public',
56+
'property_protected',
57+
'property_private',
58+
'construct',
59+
'destruct',
60+
'magic',
61+
'phpunit',
62+
'method_public_static',
63+
'method_protected_static',
64+
'method_private_static',
65+
'method_public',
66+
'method_public_abstract',
67+
'method_protected',
68+
'method_protected_abstract',
69+
'method_private',
70+
],
71+
'sort_algorithm' => 'alpha'
72+
],
73+
'ordered_imports' => true,
74+
'php_unit_construct' => true,
75+
'php_unit_method_casing' => ['case' => 'camel_case'],
76+
'php_unit_test_class_requires_covers' => true,
77+
'php_unit_dedicate_assert' => true,
78+
'phpdoc_order' => true,
79+
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
80+
'semicolon_after_instruction' => true,
81+
'single_line_comment_style' => true,
82+
'yoda_style' => true,
83+
])
84+
->setFinder($finder)
85+
;
86+
87+
return $config;

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) Carl Alexander
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<p align="center">
2+
<a href="https://ymirapp.com" target="_blank" align="center">
3+
<img src="https://cdn-std.droplr.net/files/acc_680806/69fc3k" width="280">
4+
</a>
5+
</p>
6+
7+
# Ymir Laravel Bridge
8+
9+
[![Actions Status](https://github.com/ymirapp/laravel-bridge/workflows/Continuous%20Integration/badge.svg)](https://github.com/ymirapp/laravel-bridge/actions)
10+
11+
The Ymir Laravel Bridge provides integration to run a [Laravel][2] project on [Ymir][1].
12+
13+
## Requirements
14+
15+
* PHP >= 7.4
16+
* Laravel >= 7.0
17+
18+
## Installation
19+
20+
Install the Ymir Laravel Bridge in your project using composer:
21+
22+
```
23+
$ composer require ymirapp/ymir-laravel-bridge
24+
```
25+
26+
## Contributing
27+
28+
Install dependencies using composer:
29+
30+
```console
31+
$ composer install
32+
```
33+
34+
[1]: https://ymirapp.com
35+
[2]: https://laravel.com

composer.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "ymirapp/laravel-bridge",
3+
"description": "Laravel integration for Ymir",
4+
"type": "project",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Carl Alexander",
9+
"email": "[email protected]",
10+
"homepage": "https://ymirapp.com"
11+
}
12+
],
13+
"require": {
14+
"php": "^7.4|^8.0",
15+
"aws/aws-sdk-php": "^3.80",
16+
"cachewerk/relay": "^0.10.0",
17+
"illuminate/redis": "^7.0|^8.0|^9.0|^10.0|^11.0",
18+
"illuminate/support": "^7.0|^8.0|^9.0|^10.0|^11.0"
19+
},
20+
"require-dev": {
21+
"friendsofphp/php-cs-fixer": "^3.0",
22+
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0",
23+
"php-parallel-lint/php-parallel-lint": "^1.1",
24+
"phpro/grumphp": "^1.0",
25+
"phpstan/phpstan": "^1.11.0",
26+
"sebastian/phpcpd": "^6.0.3",
27+
"symfony/filesystem": "^5.0|^6.0|^7.0"
28+
},
29+
"replace": {
30+
"ext-relay": "*"
31+
},
32+
"config": {
33+
"allow-plugins": {
34+
"phpro/grumphp": true
35+
},
36+
"optimize-autoloader": true,
37+
"preferred-install": "dist",
38+
"sort-packages": true
39+
},
40+
"autoload": {
41+
"psr-4": {
42+
"Ymir\\Bridge\\Laravel\\": "src"
43+
},
44+
"files": [
45+
"src/ymir-init.php"
46+
]
47+
},
48+
"autoload-dev": {
49+
"psr-4": {
50+
"Ymir\\Bridge\\Laravel\\Tests\\": "tests"
51+
}
52+
},
53+
"extra": {
54+
"laravel": {
55+
"providers": [
56+
"Ymir\\Bridge\\Laravel\\YmirServiceProvider"
57+
]
58+
}
59+
}
60+
}

grumphp.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
grumphp:
2+
process_timeout: 120
3+
tasks:
4+
git_commit_message:
5+
enforce_capitalized_subject: false
6+
max_subject_width: 72
7+
type_scope_conventions:
8+
- types:
9+
- build
10+
- ci
11+
- chore
12+
- deps
13+
- docs
14+
- feat
15+
- fix
16+
- perf
17+
- refactor
18+
- revert
19+
- style
20+
- test
21+
phpcpd:
22+
directory: ['./src']
23+
phpcsfixer2:
24+
allow_risky: true
25+
config: '.php-cs-fixer.dist.php'
26+
phplint: ~
27+
phpstan:
28+
ignore_patterns: ['/^(?!src)/']
29+
phpunit:
30+
always_execute: true
31+
testsuites:
32+
code_quality:
33+
tasks:
34+
- phpcpd
35+
- phpcsfixer2
36+
- phplint
37+
- phpstan

phpstan.neon

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
reportUnmatchedIgnoredErrors: false

phpunit.xml.dist

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
convertDeprecationsToExceptions="true"
11+
processIsolation="false"
12+
stopOnFailure="false"
13+
>
14+
<testsuites>
15+
<testsuite name="Integration">
16+
<directory suffix="Test.php">./tests/Integration</directory>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>

src/StorageDirectories.php

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Ymir Laravel Bridge.
7+
*
8+
* (c) Carl Alexander <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Ymir\Bridge\Laravel;
15+
16+
class StorageDirectories
17+
{
18+
/**
19+
* The storage path for the execution environment.
20+
*
21+
* @var string
22+
*/
23+
public const PATH = '/tmp/storage';
24+
25+
/**
26+
* The directories that need to be created.
27+
*
28+
* @var array<string>
29+
*/
30+
private const DIRECTORIES = [
31+
self::PATH.'/bootstrap/cache',
32+
self::PATH.'/framework/cache',
33+
self::PATH.'/framework/views',
34+
];
35+
36+
/**
37+
* Ensure the necessary storage directories exist.
38+
*/
39+
public static function create(): void
40+
{
41+
collect(self::DIRECTORIES)->filter(function ($directory) {
42+
return !is_dir($directory);
43+
})->each(function ($directory) {
44+
if (!mkdir($directory, 0755, true) && !is_dir($directory)) {
45+
throw new \RuntimeException(sprintf('Directory "%s" could not be created', $directory));
46+
}
47+
});
48+
}
49+
}

0 commit comments

Comments
 (0)