Skip to content

Commit c7774c4

Browse files
committed
Revamped the application
0 parents  commit c7774c4

Some content is hidden

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

87 files changed

+13274
-0
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
end_of_line = LF
7+
8+
[*.php]
9+
indent_style = space
10+
indent_size = 4

.env

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=
20+
###< symfony/framework-bundle ###
21+
22+
###> doctrine/doctrine-bundle ###
23+
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
24+
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
25+
#
26+
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
27+
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8.0.32&charset=utf8mb4"
28+
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
29+
#DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=16&charset=utf8"
30+
###< doctrine/doctrine-bundle ###
31+
32+
###> symfony/messenger ###
33+
# Choose one of the transports below
34+
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
35+
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
36+
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
37+
###< symfony/messenger ###
38+
39+
###> symfony/mailer ###
40+
MAILER_DSN=null://null
41+
###< symfony/mailer ###

.env.dev

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
###> symfony/framework-bundle ###
3+
APP_SECRET=6d39ac05501b4bcc7aba3882c668377b
4+
###< symfony/framework-bundle ###

.env.test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999
5+
PANTHER_APP_ENV=panther
6+
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
###> symfony/framework-bundle ###
3+
/.env.local
4+
/.env.local.php
5+
/.env.*.local
6+
/config/secrets/prod/prod.decrypt.private.php
7+
/public/bundles/
8+
/var/*
9+
!/var/data.db
10+
/vendor/
11+
###< symfony/framework-bundle ###
12+
13+
###> phpunit/phpunit ###
14+
/phpunit.xml
15+
.phpunit.result.cache
16+
###< phpunit/phpunit ###
17+
18+
###> symfony/phpunit-bridge ###
19+
.phpunit.result.cache
20+
/phpunit.xml
21+
###< symfony/phpunit-bridge ###
22+
23+
###> symfony/asset-mapper ###
24+
/public/assets/
25+
/assets/vendor/
26+
###< symfony/asset-mapper ###

LICENSE.md

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

README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
EasyAdmin Demo Application
2+
==========================
3+
4+
This project is the official [EasyAdmin][1] Demo application that showcases the
5+
main features of EasyAdmin, a popular admin generator for [Symfony][2] applications.
6+
7+
Requirements
8+
------------
9+
10+
* PHP 8.2 or higher;
11+
* PDO-SQLite PHP extension enabled;
12+
* and the [usual Symfony application requirements][2].
13+
14+
Installation
15+
------------
16+
17+
Run this command with [Composer][4]:
18+
19+
```bash
20+
$ composer create-project easyCorp/easyadmin-demo my_project
21+
```
22+
23+
Usage
24+
-----
25+
26+
There's no need to configure anything to run the application. If you have
27+
[installed Symfony CLI][5], run this command:
28+
29+
```bash
30+
$ cd my_project/
31+
$ symfony serve
32+
```
33+
34+
Then access the application in your browser at the given URL (<https://localhost:8000> by default).
35+
36+
If you don't have the Symfony binary installed, run `php -S localhost:8000 -t public/`
37+
to use the built-in PHP web server or [configure a web server][6] to run the application.
38+
39+
Contributing
40+
------------
41+
42+
This demo application is open source but it does not accept pull requests with
43+
unsolicited features. If you have a feature idea, create an issue to discuss it
44+
before implementing it. Pull requests that fix bugs are welcome.
45+
46+
License
47+
-------
48+
49+
This demo application is published under the MIT license. See LICENSE.md for details.
50+
51+
[1]: https://github.com/EasyCorp/EasyAdminBundle/
52+
[2]: https://symfony.com
53+
[3]: https://github.com/symfony/demo
54+
[4]: https://getcomposer.org/
55+
[5]: https://symfony.com/download
56+
[6]: https://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html

assets/admin.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styles/admin.css';

assets/app.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import './bootstrap.js';
2+
/*
3+
* Welcome to your app's main JavaScript file!
4+
*
5+
* This file will be included onto the page via the importmap() Twig function,
6+
* which should already be in your base.html.twig.
7+
*/
8+
import './styles/app.css';
9+
10+
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');

assets/bootstrap.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { startStimulusApp } from '@symfony/stimulus-bundle';
2+
3+
const app = startStimulusApp();
4+
// register any custom, 3rd party controllers here
5+
// app.register('some_controller_name', SomeImportedController);

assets/controllers.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"controllers": {
3+
"@symfony/ux-turbo": {
4+
"turbo-core": {
5+
"enabled": true,
6+
"fetch": "eager"
7+
},
8+
"mercure-turbo-stream": {
9+
"enabled": false,
10+
"fetch": "eager"
11+
}
12+
}
13+
},
14+
"entrypoints": []
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;
2+
var tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;
3+
4+
// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager
5+
document.addEventListener('submit', function (event) {
6+
var csrfField = event.target.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
7+
8+
if (!csrfField) {
9+
return;
10+
}
11+
12+
var csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
13+
var csrfToken = csrfField.value;
14+
15+
if (!csrfCookie && nameCheck.test(csrfToken)) {
16+
csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);
17+
csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));
18+
}
19+
20+
if (csrfCookie && tokenCheck.test(csrfToken)) {
21+
var cookie = csrfCookie + '_' + csrfToken + '=' + csrfCookie + '; path=/; samesite=strict';
22+
document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
23+
}
24+
});
25+
26+
// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie
27+
// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked
28+
document.addEventListener('turbo:submit-start', function (event) {
29+
var csrfField = event.detail.formSubmission.formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
30+
31+
if (!csrfField) {
32+
return;
33+
}
34+
35+
var csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
36+
37+
if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
38+
event.detail.formSubmission.fetchRequest.headers[csrfCookie] = csrfField.value;
39+
}
40+
});
41+
42+
// When @hotwired/turbo handles form submissions, remove the CSRF cookie once a form has been submitted
43+
document.addEventListener('turbo:submit-end', function (event) {
44+
var csrfField = event.detail.formSubmission.formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
45+
46+
if (!csrfField) {
47+
return;
48+
}
49+
50+
var csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
51+
52+
if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
53+
var cookie = csrfCookie + '_' + csrfField.value + '=0; path=/; samesite=strict; max-age=0';
54+
55+
document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
56+
}
57+
});
58+
59+
/* stimulusFetch: 'lazy' */
60+
export default 'csrf-protection-controller';
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
3+
/*
4+
* This is an example Stimulus controller!
5+
*
6+
* Any element with a data-controller="hello" attribute will cause
7+
* this controller to be executed. The name "hello" comes from the filename:
8+
* hello_controller.js -> "hello"
9+
*
10+
* Delete this file or adapt it for your use!
11+
*/
12+
export default class extends Controller {
13+
connect() {
14+
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
15+
}
16+
}

assets/styles/admin.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
h1.page-title { font-size: 21px; }
2+
p.description { max-width: 60ch; text-wrap: balance; }
3+
4+
#dashboard .content-top { display: none; }
5+
#regenerate-fixtures .content-top { display: none; }
6+

assets/styles/app.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: skyblue;
3+
}

bin/console

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use App\Kernel;
5+
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
7+
if (!is_dir(dirname(__DIR__).'/vendor')) {
8+
throw new LogicException('Dependencies are missing. Try running "composer install".');
9+
}
10+
11+
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
12+
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
13+
}
14+
15+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
16+
17+
return function (array $context) {
18+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
19+
20+
return new Application($kernel);
21+
};

bin/phpunit

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
if (!ini_get('date.timezone')) {
5+
ini_set('date.timezone', 'UTC');
6+
}
7+
8+
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
9+
if (PHP_VERSION_ID >= 80000) {
10+
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
11+
} else {
12+
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
13+
require PHPUNIT_COMPOSER_INSTALL;
14+
PHPUnit\TextUI\Command::main();
15+
}
16+
} else {
17+
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
18+
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
19+
exit(1);
20+
}
21+
22+
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
23+
}

0 commit comments

Comments
 (0)