Skip to content

Commit

Permalink
Migrate project to Symfony (#21)
Browse files Browse the repository at this point in the history
* Migrate project from Silex to Symfony

* Update to Symfony 7.0.8

* Update to Symfony 7.1.1

* Reference Silex old version in readme

* Update to Symfony 7.1.2
  • Loading branch information
romibuzi committed Jun 29, 2024
1 parent ebac238 commit a88aaf3
Show file tree
Hide file tree
Showing 95 changed files with 6,118 additions and 3,117 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_ENV=prod
APP_SECRET=s3creT

AWS_REGION=eu-west-1
AWS_ACCOUNT=XXX
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
php: ['7.4', '8.2']
php: ['8.2', '8.3']

steps:
- uses: actions/checkout@v3
Expand All @@ -29,8 +29,8 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Copy example config
run: cp app/config.php.dist app/config.php
- name: Copy .env.example
run: cp .env.example .env

- name: Install dependencies
run: make install-dev
Expand Down
23 changes: 16 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
bin/
vendor/
.env

# local specific config
# old local specific config
app/config.php

var/majordome.db
###> symfony/framework-bundle ###
bin/*
!bin/console

var/logs/*
!var/logs/.gitkeep
/var/
/vendor/
###< symfony/framework-bundle ###

var/code-coverage
###> phpunit/phpunit ###
.phpunit.cache
.phpunit.result.cache
###< phpunit/phpunit ###

###> squizlabs/php_codesniffer ###
/.phpcs-cache
###< squizlabs/php_codesniffer ###
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
FROM php:8.2-cli

ENV COMPOSER_ALLOW_SUPERUSER=1

RUN apt-get update

RUN apt-get -y install libzip-dev sqlite3

RUN docker-php-ext-install zip

RUN curl -sS https://getcomposer.org/installer -o composer-setup.php
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php

RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer -y

WORKDIR /opt/majordome

COPY . .

RUN make install
RUN make install-dev

RUN make install-db

CMD ["php", "-S", "0.0.0.0:8080", "-t", "web/"]
CMD ["php", "-S", "0.0.0.0:8080", "-t", "public/"]

EXPOSE 8080
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Romain Ardiet
Copyright (c) 2024 Romain Ardiet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
40 changes: 25 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
HOST=127.0.0.1
PORT=8080

ifdef AWS_ACCESS_KEY_ID
AWS_ACCESS_ARG=-e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID)
endif

ifdef AWS_SECRET_ACCESS_KEY
AWS_SECRET_ARG=-e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY)
endif

help:
@echo " install"
@echo " Install dependencies via composer."
Expand All @@ -20,43 +28,45 @@ help:
@echo " Run Majordome web interface through docker."

install:
composer install --no-dev
APP_ENV=prod composer install --no-dev

install-dev:
composer install
APP_ENV=dev composer install

install-db:
php bin/console doctrine:database:create --no-interaction
php bin/console doctrine:migrations:migrate --no-interaction

test:
bin/phpcs
bin/phpunit

run:
app/console majordome:run-aws
bin/console majordome:run-aws

run-web:
php -S $(HOST):$(PORT) -t web/
php -S $(HOST):$(PORT) -t public/

docker-build:
docker build --rm -t majordome:latest .

ifdef AWS_ACCESS_KEY_ID
AWS_ACCESS_ARG=-e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID)
endif

ifdef AWS_SECRET_ACCESS_KEY
AWS_SECRET_ARG=-e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY)
endif
if [ ! -f var/majordome_dev.db ]; then \
mkdir -p var/; \
docker create --name majordome-db majordome:latest; \
docker cp majordome-db:/opt/majordome/var/majordome_dev.db var/majordome_dev.db; \
docker rm -f majordome-db; \
fi

docker-run:
docker run --rm \
$(AWS_ACCESS_ARG) $(AWS_SECRET_ARG) \
--mount type=bind,source=${PWD}/app/config.php,target=/opt/majordome/app/config.php \
--mount type=bind,source=${PWD}/.env,target=/opt/majordome/.env \
-v ${PWD}/var/:/opt/majordome/var/ \
-v ${HOME}/.aws:/root/.aws:ro \
-it --entrypoint app/console \
-it --entrypoint bin/console \
majordome:latest majordome:run-aws

docker-run-web:
docker run --rm \
--mount type=bind,source=${PWD}/app/config.php,target=/opt/majordome/app/config.php \
--mount type=bind,source=${PWD}/.env,target=/opt/majordome/.env \
-v ${PWD}/var/:/opt/majordome/var/ \
-p 8080:8080 majordome:latest
Binary file modified README.md
Binary file not shown.
99 changes: 0 additions & 99 deletions app/app.php

This file was deleted.

55 changes: 0 additions & 55 deletions app/config.php.dist

This file was deleted.

17 changes: 0 additions & 17 deletions app/console

This file was deleted.

11 changes: 0 additions & 11 deletions app/routing.php

This file was deleted.

21 changes: 0 additions & 21 deletions app/schema.sql

This file was deleted.

17 changes: 17 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php

use Majordome\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
Loading

0 comments on commit a88aaf3

Please sign in to comment.