Skip to content

Commit 1634f4e

Browse files
committed
init base
0 parents  commit 1634f4e

File tree

4 files changed

+185
-0
lines changed

4 files changed

+185
-0
lines changed

LICENSE

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

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# FrankenPHP Base for Magento 2
2+
3+
[![Latest Stable Version](https://img.shields.io/packagist/v/opengento/magento2-frankenphp-base.svg?style=flat-square)](https://packagist.org/packages/opengento/magento2-frankenphp-base)
4+
[![License: MIT](https://img.shields.io/github/license/opengento/magento2-frankenphp-base.svg?style=flat-square)](./LICENSE)
5+
[![Packagist](https://img.shields.io/packagist/dt/opengento/magento2-frankenphp-base.svg?style=flat-square)](https://packagist.org/packages/opengento/magento2-frankenphp-base/stats)
6+
[![Packagist](https://img.shields.io/packagist/dm/opengento/magento2-frankenphp-base.svg?style=flat-square)](https://packagist.org/packages/opengento/magento2-frankenphp-base/stats)
7+
8+
Magento 2 Base for FrankenPHP
9+
10+
- [Setup](#setup)
11+
- [Composer installation](#composer-installation)
12+
- [Setup the base](#setup-the-module)
13+
- [Features](#features)
14+
- [Support](#support)
15+
- [Authors](#authors)
16+
- [License](#license)
17+
18+
## Setup
19+
20+
Magento 2 Open Source or Commerce edition is required.
21+
22+
### Composer installation
23+
24+
Run the following composer command:
25+
26+
```
27+
composer require opengento/magento2-frankenphp-base
28+
```
29+
30+
### Setup the module
31+
32+
Run the following magento command:
33+
34+
```
35+
bin/magento setup:upgrade
36+
```
37+
38+
**If you are in production mode, do not forget to recompile and redeploy the static resources.**
39+
40+
## Features
41+
42+
This base allows to run Magento 2 with FrankenPHP worker mode.
43+
44+
## Support
45+
46+
Raise a new [request](https://github.com/opengento/magento2-frankenphp-base/issues) to the issue tracker.
47+
48+
## Authors
49+
50+
- **Opengento Community** - *Lead* - [![Twitter Follow](https://img.shields.io/twitter/follow/opengento.svg?style=social)](https://twitter.com/opengento)
51+
- **Thomas Klein** - *Maintainer* - [![GitHub followers](https://img.shields.io/github/followers/thomas-kl1.svg?style=social)](https://github.com/thomas-kl1)
52+
- **Contributors** - *Contributor* - [![GitHub contributors](https://img.shields.io/github/contributors/opengento/magento2-frankenphp-base.svg?style=flat-square)](https://github.com/opengento/magento2-frankenphp-base/graphs/contributors)
53+
54+
## License
55+
56+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) details.
57+
58+
***That's all folks!***

composer.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "opengento/magento2-frankenphp-base",
3+
"description": "Magento 2 Base for FrankenPHP",
4+
"keywords": [
5+
"php",
6+
"magento",
7+
"magento2",
8+
"frankenphp",
9+
"application"
10+
],
11+
"require": {
12+
"magento/magento2-base": "*",
13+
"opengento/module-application": "^1.0"
14+
},
15+
"require-dev": {
16+
"magento/magento-coding-standard": "^33",
17+
"roave/security-advisories": "dev-latest"
18+
},
19+
"type": "magento2-component",
20+
"license": [
21+
"MIT"
22+
],
23+
"homepage": "https://github.com/opengento/magento2-application",
24+
"authors": [
25+
{
26+
"name": "Opengento Team",
27+
"email": "[email protected]",
28+
"homepage": "https://opengento.fr/",
29+
"role": "lead"
30+
},
31+
{
32+
"name": "Thomas Klein",
33+
"email": "[email protected]",
34+
"homepage": "https://www.linkedin.com/in/thomas-klein/",
35+
"role": "maintainer"
36+
}
37+
],
38+
"support": {
39+
"source": "https://github.com/opengento/magento2-application",
40+
"issues": "https://github.com/opengento/magento2-application/issues"
41+
},
42+
"extra": {
43+
"map": [
44+
[
45+
"pub/worker.php",
46+
"pub/worker.php"
47+
]
48+
]
49+
}
50+
}

pub/worker.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © OpenGento, All rights reserved.
4+
* See LICENSE bundled with this library for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
if (!($_SERVER['FRANKENPHP_WORKER_ENABLE'] ?? false)) {
9+
echo <<<HTML
10+
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
11+
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
12+
<h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
13+
FrankenPHP Worker mode is not enabled</h3>
14+
</div>
15+
<p>{$e->getMessage()}</p>
16+
</div>
17+
HTML;
18+
http_response_code(500);
19+
exit(1);
20+
}
21+
22+
try {
23+
require __DIR__ . '/../app/bootstrap.php';
24+
} catch (\Exception $e) {
25+
echo <<<HTML
26+
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
27+
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
28+
<h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
29+
Autoload error</h3>
30+
</div>
31+
<p>{$e->getMessage()}</p>
32+
</div>
33+
HTML;
34+
http_response_code(500);
35+
exit(1);
36+
}
37+
38+
$bootstrapPool = new \Opengento\Application\ObjectManager\BootstrapPool();
39+
$handler = static function () use ($bootstrapPool): void {
40+
try {
41+
$bootstrap = $bootstrapPool->get();
42+
$app = $bootstrap->createApplication(\Opengento\Application\App\Application::class);
43+
if ($app !== null) {
44+
$bootstrap->run($app);
45+
}
46+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
47+
echo $e->getMessage();
48+
exit(1);
49+
}
50+
};
51+
52+
$maxRequests = (int)($_SERVER['MAX_REQUESTS'] ?? 0);
53+
$nbRequests = 0;
54+
do {
55+
$keepRunning = \frankenphp_handle_request($handler);
56+
} while ($keepRunning && !$maxRequests && $nbRequests++ < $maxRequests);

0 commit comments

Comments
 (0)