Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 18, 2024
0 parents commit d2064a4
Show file tree
Hide file tree
Showing 236 changed files with 43,788 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
end_of_line = LF

[*.php]
indent_style = space
indent_size = 4
35 changes: 35 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=2ca64f8d83b9e89f5f19d672841d6bb8
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database.sqlite
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8&charset=utf8mb4"
# DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=15&charset=utf8"
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###
7 changes: 7 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
DATABASE_URL=sqlite:///%kernel.project_dir%/data/database_test.sqlite
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Example
on:
push:
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run linting and tests
uses: fluentci-io/setup-fluentci@v5
with:
wasm: true
pipeline: symfony
args: |
container_lint
doctrine_lint
phpstan
phpunit
twig_lint
xliff_lint
yaml_lint
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/public/build/fonts/glyphicons-*
/public/build/images/glyphicons-*

.php-version

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
###> symfony/webpack-encore-bundle ###
/node_modules/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
43 changes: 43 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

$fileHeaderComment = <<<COMMENT
This file is part of the Symfony package.
(c) Fabien Potencier <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
COMMENT;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('config')
->exclude('var')
->exclude('public/bundles')
->exclude('public/build')
// exclude files generated by Symfony Flex recipes
->notPath('bin/console')
->notPath('public/index.php')
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'php_unit_strict' => true,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'blank_line_between_import_groups' => false,
])
->setFinder($finder)
->setCacheFile(__DIR__.'/var/.php-cs-fixer.cache')
;
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Contributing
============

The Symfony Demo application is an open source project. Contributions made by
the community are welcome. Send us your ideas, code reviews, pull requests and
feature requests to help us improve this project. All contributions must follow
the [usual Symfony contribution requirements](https://symfony.com/doc/current/contributing/index.html).
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Tsiry Sandratraina <[email protected]>

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.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# FluentCI CI/CD demo for PHP Symfony

[![ci](https://github.com/fluentci-demos/fluentci-demo-symfony/actions/workflows/ci.yml/badge.svg)](https://github.com/fluentci-demos/fluentci-demo-symfony/actions/workflows/ci.yml)

This is an example application and CI/CD pipeline showing how to build, test a PHP Symfony application using FluentCI.

47 changes: 47 additions & 0 deletions assets/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import './styles/admin.scss';
import 'typeahead.js';
import Bloodhound from "bloodhound-js";
import 'bootstrap-tagsinput';

$(function() {
// Bootstrap-tagsinput initialization
// https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
var $input = $('input[data-toggle="tagsinput"]');
if ($input.length) {
var source = new Bloodhound({
local: $input.data('tags'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
datumTokenizer: Bloodhound.tokenizers.whitespace
});
source.initialize();

$input.tagsinput({
trimValue: true,
focusClass: 'focus',
typeaheadjs: {
name: 'tags',
source: source.ttAdapter()
}
});
}
});

// Handling the modal confirmation message.
$(document).on('submit', 'form[data-confirmation]', function (event) {
var $form = $(this),
$confirm = $('#confirmationModal');

if ($confirm.data('result') !== 'yes') {
//cancel submit event
event.preventDefault();

$confirm
.off('click', '#btnYes')
.on('click', '#btnYes', function () {
$confirm.data('result', 'yes');
$form.find('input[type="submit"]').attr('disabled', 'disabled');
$form.trigger('submit');
})
.modal('show');
}
});
20 changes: 20 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import './styles/app.scss';

// loads the Bootstrap plugins
import 'bootstrap/js/dist/alert';
import 'bootstrap/js/dist/collapse';
import 'bootstrap/js/dist/dropdown';
import 'bootstrap/js/dist/tab';
import 'bootstrap/js/dist/modal';
import 'jquery'

// loads the code syntax highlighting library
import './js/highlight.js';

// Creates links to the Symfony documentation
import './js/doclinks.js';

// start the Stimulus application
import './bootstrap';

import './js/flatpicker';
11 changes: 11 additions & 0 deletions assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';

// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.[jt]sx?$/
));

// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
14 changes: 14 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"controllers": {
"@symfony/ux-live-component": {
"live": {
"enabled": true,
"fetch": "eager",
"autoimport": {
"@symfony/ux-live-component/dist/live.min.css": true
}
}
}
},
"entrypoints": []
}
Empty file added assets/controllers/.gitignore
Empty file.
36 changes: 36 additions & 0 deletions assets/controllers/login-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// A Stimulus JavaScript controller file
// https://stimulus.hotwired.dev
// @see templates/security/login.html.twig
// More info on Symfony UX https://ux.symfony.com

import { Controller } from '@hotwired/stimulus';

/*
* The following line makes this controller "lazy": it won't be downloaded until needed
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
*/
/* stimulusFetch: 'lazy' */
export default class extends Controller {
static targets = ['username', 'password']

// /!\ in a real application, the user/password should never be hardcoded /!\
// but for the demo application, it's very convenient to do so

prefillJohnUser() {
this.usernameTarget.value = 'john_user'
this.passwordTarget.value = 'kitten'
}

prefillJaneAdmin() {
this.usernameTarget.value = 'jane_admin'
this.passwordTarget.value = 'kitten'
}

togglePasswordInputType() {
if ('password' === this.passwordTarget.type) {
this.passwordTarget.type = 'text'
} else {
this.passwordTarget.type = 'password'
}
}
}
63 changes: 63 additions & 0 deletions assets/js/doclinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

// Wraps some elements in anchor tags referencing to the Symfony documentation
$(function() {
var $modal = $('#sourceCodeModal');
var $controllerCode = $modal.find('code.php');
var $templateCode = $modal.find('code.twig');

function anchor(url, content) {
return '<a class="doclink" target="_blank" href="' + url + '">' + content + '</a>';
};

function wrap(content, links) {
return content.replace(
new RegExp(Object.keys(links).join('|'), 'g'),
token => anchor(links[token], token)
);
};

// Wraps links to the Symfony documentation
$modal.find('.hljs-comment').each(function() {
$(this).html($(this).html().replace(/https:\/\/symfony.com\/doc\/[\w/.#-]+/g, function(url) {
return anchor(url, url);
}));
});

// Wraps Symfony's attributes
var attributes = {
'Cache': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html',
'IsGranted': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#isgranted',
'ParamConverter': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html',
'Route': 'https://symfony.com/doc/current/routing.html#creating-routes-as-attributes-or-annotations',
'Security': 'https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html#security'
};

$controllerCode.find('.hljs-meta').each(function() {
var src = $(this).text();

$(this).html(wrap(src, attributes));
});

// Wraps Twig's tags
$templateCode.find('.hljs-template-tag + .hljs-name').each(function() {
var tag = $(this).text();

if ('else' === tag || tag.match(/^end/)) {
return;
}

var url = 'https://twig.symfony.com/doc/3.x/tags/' + tag + '.html#' + tag;

$(this).html(anchor(url, tag));
});

// Wraps Twig's functions
$templateCode.find('.hljs-template-variable > .hljs-name').each(function() {
var func = $(this).text();

var url = 'https://twig.symfony.com/doc/3.x/functions/' + func + '.html#' + func;

$(this).html(anchor(url, func));
});
});
Loading

0 comments on commit d2064a4

Please sign in to comment.