Commit 0267ac53 authored by Avris's avatar Avris

init

parents
# This file is a "template" of which env vars need to be defined for your application
# Copy this file to .env file for development, create environment variables when deploying to production
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=b80d8bb976337d35104aa8c2b4660577
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS=localhost,example.com
###< symfony/framework-bundle ###
###> symfony/framework-bundle ###
/.env
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###
/license.yaml
# Avris License
Instead of attaching a license file to all of your projects,
you can generate a website with a license and have all the projects link to it.
That will let you keep it up-to-date.
## Installation
git clone git@gitlab.com:Avris/License.git
cd License
composer install
cp license.yaml.dist license.yaml
## Customization
You can modify the `license.yaml` file to your needs, in particular:
- add the copyright information (name, email, website)
- name, short name and content of the license
- theme (from `templates/theme/*`) and color (used by some themes and to generate a favicon)
- turn on/off the avatar
- footer
Since the year of first publication will differ for different projects, it is configurable in a GET parameter:
- `/?year=2014` will render `Copyright © 2014`,
- `/?year=2014i` will render `Copyright © 2014 – 2018`,
- by default a year is not displayed (it's not necessary anyway).
The license is also available in plain text at `/license.txt`.
## Copyright
* **Author:** Andrzej Prusinowski [(Avris.it)](https://avris.it)
* **Huge inspiration**: [@remy](https://github.com/remy/mit-license)
* **Default license text**: [@jamiebuilds](https://github.com/jamiebuilds/license)
* **Licence:** [MIT](https://mit.avris.it)
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Dotenv\Dotenv;
set_time_limit(0);
require __DIR__.'/../vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
}
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
if ($debug) {
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new Kernel($env, $debug);
$application = new Application($kernel);
$application->run($input);
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"erusev/parsedown": "^1.7",
"imagine/imagine": "^0.7.1",
"sensio/framework-extra-bundle": "^5.1",
"symfony/apache-pack": "^1.0",
"symfony/console": "*",
"symfony/expression-language": "*",
"symfony/flex": "^1.1",
"symfony/framework-bundle": "*",
"symfony/monolog-bundle": "^3.3",
"symfony/process": "*",
"symfony/serializer-pack": "*",
"symfony/translation": "*",
"symfony/twig-bundle": "*",
"symfony/validator": "*",
"symfony/web-link": "*",
"symfony/yaml": "*"
},
"require-dev": {
"symfony/debug-pack": "*",
"symfony/dotenv": "*",
"symfony/maker-bundle": "^1.7",
"symfony/profiler-pack": "*",
"symfony/web-server-bundle": "*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.1.*"
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
];
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"
services:
EasyCorp\EasyLog\EasyLogHandler:
public: false
arguments: ['%kernel.logs_dir%/%kernel.environment%.log']
#// FIXME: How to add this configuration automatically without messing up with the monolog configuration?
#monolog:
# handlers:
# buffered:
# type: buffer
# handler: easylog
# channels: ['!event']
# level: debug
# easylog:
# type: service
# id: EasyCorp\EasyLog\EasyLogHandler
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
framework:
router:
strict_requirements: true
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }
framework:
secret: '%env(APP_SECRET)%'
#default_locale: en
#csrf_protection: true
#http_method_override: true
# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: ~
#esi: true
#fragments: true
php_errors:
log: true
cache:
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The app cache caches to the filesystem by default.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_404s:
# regex: exclude all 404 errors from the logs
- ^/
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"
deprecation_filter:
type: filter
handler: deprecation
max_level: info
channels: ["php"]
framework:
router:
strict_requirements: ~
sensio_framework_extra:
router:
annotations: false
framework:
test: true
session:
storage_id: session.storage.mock_file
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }
framework:
default_locale: '%locale%'
translator:
paths:
- '%kernel.project_dir%/translations'
fallbacks:
- '%locale%'
twig:
paths: ['%kernel.project_dir%/templates']
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
framework:
validation:
email_validation_mode: html5
#index:
# path: /
# controller: App\Controller\DefaultController::index
controllers:
resource: ../../src/Controller/
type: annotation
_errors:
resource: '@TwigBundle/Resources/config/routing/errors.xml'
prefix: /_error
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
parameters:
locale: 'en'
services:
_defaults:
autowire: true
autoconfigure: true
public: false
bind:
$projectDir: '%kernel.project_dir%'
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
Parsedown:
class: Parsedown
Imagine\Image\ImagineInterface: '@Imagine\Gd\Imagine'
Imagine\Gd\Imagine: ~
App\Service\FaviconService:
arguments:
$fontFile: '%kernel.project_dir%/asset/Ubuntu-B.ttf'
name: The MIT License
shortName: MIT
owner:
name: <<<YOUR NAME HERE>>>
email: <<<YOUR EMAIL HERE>>>
website: <<<YOUR WEBSITE HERE>>>
theme: material
color: '#514a8a'
avatar: true
# License source: https://github.com/jamiebuilds/license
content: |
This license is granted to everyone except for the following entities and
any of their subsidiaries:
- "Microsoft Corporation" (for working with ICE)
- "Palantir Technologies" (for working with ICE)
- "Amazon.com, Inc." (for abusive treatment of workers and for working with ICE)
- "Northeastern University" (for working with ICE)
- "Ernst & Young" (for working with ICE)
- "Thomson Reuters" (for working with ICE)
- "Motorola Solutions" (for working with ICE)
- "Deloitte Consulting LLP" (for working with ICE)
- "John Hopkins University" (for working with ICE)
- "Dell Inc" (for working with ICE)
- "Xerox Corporation" (for working with ICE)
- "Canon Inc" (for working with ICE)
- "Vermont State Colleges" (for working with ICE)
- "Charter Communications"/"Spectrum"/"Time Warner Cable" (for working with ICE)
- "LinkedIn Corporation" (for working with ICE)
- "United Parcel Service Co" (for working with ICE)
- "Walmart Inc" (for abusive treatment of workers)
- "Sears Holding Corporation" (for abusive treatment of workers)
- "Apple Inc" (for abusive treatment of workers)
- "Tyson Foods Inc" (for abusive treatment of workers)
- "Target Corporation" (for union busting and anti-union propaganda)
- "The H&M group" (for abusive treatment of workers)
- "Tesla, Inc" (for abusive treatment of workers)
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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
footer: |
Website source: [gitlab.com/Avris/License](https://gitlab.com/Avris/License).
License source: [github.com/jamiebuilds/license](https://github.com/jamiebuilds/license).
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex index.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks
# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
# to the front controller "/index.php" but be rewritten to "/index.php/index".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the index.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/index.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
# endless redirect loop (request -> rewrite to front controller ->
# redirect -> request -> ...).
# So in case you get a "too many redirects" error or you always get redirected
# to the start page because your Apache does not expose the REDIRECT_STATUS
# environment variable, you have 2 choices:
# - disable this feature by commenting the following 2 lines or
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# Rewrite all other queries to the front controller.
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 307 ^/$ /index.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
<?php
use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../vendor/autoload.php';
// The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
}
$env = $_SERVER['APP_ENV'] ?? 'dev';
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
if ($debug) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts(explode(',', $trustedHosts));
}
$kernel = new Kernel($env, $debug);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
<?php
namespace App\Controller;
use App\Entity\License;
use App\Service\FaviconService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class LicenseController extends AbstractController
{
/**
* @Route("/")
* @Route("/license.{_format}", requirements={"_format": "html|txt"})
*/
public function show(Request $request)
{
return $this->render(
sprintf('license/show.%s.twig', $request->getRequestFormat()),
[
'year' => $request->query->get('year'),
]
);
}
/**
* @Route("/favicon.png")
*/
public function favicon(string $projectDir, FaviconService $faviconService)
{
$license = License::fromFile($projectDir . '/license.yaml');
return new Response(
$faviconService->generate($license),
200,
['content-type' => 'image/png']
);
}
}
<?php
namespace App\Entity;
use Symfony\Component\Yaml\Yaml;
final class License
{
/** @var string */
private $name;
/** @var string|null */
private $shortName;
/** @var string */
private $ownerName;
/** @var string */
private $ownerEmail;
/** @var string|null */
private $ownerWebsite;
/** @var string */
private $content;
/** @var string */
private $theme;
/** @var string */
private $color;
/** @var bool */
private $avatar;
/** @var string|null */
private $footer;
public static function fromFile(string $path): self
{
if (!file_exists($path)) {
throw new \Exception(sprintf('File "%s" not found. You can create it based on license.yaml.dist', $path));
}
$data = Yaml::parse(file_get_contents($path));
$license = new self;
$license->name = $data['name'];
$license->shortName = $data['shortName'] ?? null;
$license->ownerName = $data['owner']['name'];
$license->ownerEmail = $data['owner']['email'];
$license->ownerWebsite = $data['owner']['website'] ?? null;
$license->content = $data['content'];
$license->theme = $data['theme'] ?? 'material';
$license->color = $data['color'] ?? '#4a8a67';
$license->avatar = (bool) $data['avatar'] ?? false;
$license->footer = $data['footer'] ?? false;
return $license;
}
public function getName(): string
{
return $this->name;
}
public function getShortName(): ?string
{
return $this->shortName;
}
public function getOwnerName(): string
{
return $this->ownerName;
}
public function getOwnerEmail(): string
{
return $this->ownerEmail;
}
public function getOwnerWebsite(): ?string
{
return $this->ownerWebsite;
}
public function getContent(): string
{
return $this->content;
}
public function getTheme(): string
{
return $this->theme;
}
public function getColor(): string
{
return $this->color;
}
public function isAvatar(): bool
{
return $this->avatar;
}
public function getFooter(): ?string