Git Product home page Git Product logo

thecodingmachine / symfony-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
102.0 102.0 40.0 9.97 MB

An example of an application built with Symfony 5, GraphQL and Nuxt.js

Home Page: https://thecodingmachine.github.io/symfony-boilerplate

Makefile 0.61% Ruby 0.69% Shell 0.12% Dockerfile 0.41% CSS 8.74% PHP 50.15% Twig 0.78% JavaScript 9.51% SCSS 15.16% Vue 13.83%
clean-architecture docker docker-compose graphql minio mysql nuxtjs pest redis s3 ssr symfony vagrant vuejs

symfony-boilerplate's Introduction

Symfony Boilerplate

Symfony Boilerplate

Documentation


This is a template of a README. Adapt it according to the comments and your needs.


Symfony Boilerplate

Replace this title and the following description with your project name and description.

A web application built with Nuxt.js 2, Symfony 5.4 (LTS), and GraphQL 5.

Setup

Prerequisites

Linux

Install the latest version of Docker and Docker Compose.

macOS

Consider installing Vagrant and VirtualBox.

Indeed, Docker currently has substantial performance issues on macOS, and using Vagrant allows us to have an almost Linux-like experience regarding performances.

Windows

Consider using a Linux-like terminal to run the Makefile commands. Vagrant might also be a solution regarding performances.

If not possible, you may also directly run the commands specified in the Makefile. For instance, instead of running make up, run docker-compose up -d.

Hosts

Update your hosts file with the following entries:

127.0.0.1   traefik.symfony-boilerplate.localhost
127.0.0.1   symfony-boilerplate.localhost
127.0.0.1   api.symfony-boilerplate.localhost
127.0.0.1   phpmyadmin.symfony-boilerplate.localhost
127.0.0.1   minio.symfony-boilerplate.localhost
127.0.0.1   mailhog.symfony-boilerplate.localhost

Update the domain with the one used in your project.

On Linux and macOS, run sudo nano /etc/hosts to edit it.

On Windows, edit the file C:\Windows\System32\drivers\etc\hosts with administrative privileges.

First start

Copy the file .env.dist to a file named .env. For instance:

cp .env.dist .env

Edit the .env.dist by updating the default values of DOMAIN, MYSQL_DATABASE and APP_SECRET environment variables.


Vagrant user

"Comment" the STARTUP_COMMAND_3 and STARTUP_COMMAND_4 environment variables from the api service in the docker-compose.yml file.

Next, run:

docker-compose up webapp api

📣  This command start the webapp and api service. While booting, these services install the JavaScript and PHP dependencies. We cannot do that directly in the Vagrant VM as yarn and composer install fail miserably the first time.

Once the services have installed the dependencies, you may stop them with:

CTRL+C
docker-compose down

Don't forget to uncomment the previous environments variables from the api service in the docker-compose.yml file.

Next, check there is no application running on port 80 (like Apache or another virtual machine).

If OK, run make vagrant, then vagrant up, and finally vagrant ssh to connect to the virtual machine. From here, you'll be able to run all the next commands like Linux users!

Update the variable VAGRANT_PROJECT_NAME from the .env and .env.dist files with your project name. Only use alphanumeric characters (no spaces, distinguish words with _ or -).


Next, make sure there is no application running on port 80 (Vagrant users can skip this check).

Good? You may now start all the Docker containers with the following commands:

make up

It may take some time as each container will also set up itself, such as installing dependencies (PHP, JavaScript, etc.), compiling sources (JavaScript), or running migrations to set up the database structure.

📣  In some cases, the api service will try to run the migrations before the mysql service is ready. If so, restart the api service with docker-compose up -d api.

The containers will be ready faster next time you run this command as the first run is doing most of the setup.

Once everything is ready, the following endpoints should be available:

Update the domain with the one used in your project.

You may now enter the api service and load the development data:

make api
php bin/console app:fixtures:dev
exit

Last but not least, start the message consumer with:

make consume

Cypress

We have added cypress for front-end testing, for now it is in webapp directory. It is recommended to remove it went deploy in production for security reasons:

Open cypress for testing

In the main directory

cd src/webapp
./node_modules/.bin/cypress open

What's next?

Configuring Git

Git should ignore globally some folders like those generated by your IDE and Vagrant.

If not already done, you should tell Git where to find your global .gitignore file.

For instance, on Linux/macOS/Windows git bash:

git config --global core.excludesfile '~/.gitignore'

Windows cmd:

git config --global core.excludesfile "%USERPROFILE%\.gitignore"

Windows PowerShell:

git config --global core.excludesfile "$Env:USERPROFILE\.gitignore"

Then create the global .gitignore file according to the location specified previously.

You may now edit it, according to your environment, with:

# IDE
.idea
.vscode
# MacOS
.DS_Store
# Vagrant
.vagrant

Documentations

Make sure you have read the following documentations:

Day-to-day guidelines

In-depth explanations

How to stop the stack?

As simple as the make up command, run make down to stop the entire Docker Compose stack.

If you're a Vagrant user, you may also stop the virtual machine with vagrant halt.

If you're not going to work on the project for a while, you may also destroy the virtual machine using vagrant destroy.

How to view the logs of the Docker containers?

All aggregated logs:

docker-compose logs -f

Logs of one service:

docker-compose logs -f SERVICE_NAME

For instance, if you want the logs of the api service:

docker-compose logs -f api

symfony-boilerplate's People

Contributors

dependabot[bot] avatar dredwardpcb avatar dsavina avatar gulien avatar homersimpsons avatar jeremydolle avatar mistraloz avatar moufmouf avatar mrbig00 avatar ndouop avatar nguyenk avatar patrick-mota avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony-boilerplate's Issues

Would be pratical to know wich file come from the boilerplate

I would find practical for migrating project to the boilerplate to know which files come from the boilerplate. That way it is easier to know if the example files come from our project are from the boilerplate for example.

Something like :

This file come from the Symfony-Boilerplate, you may update it or delete it depending on your project needs

xDebug

Add a documentation on xDebug.

Update the stack to make xDebug works with Vagrant.

[Documentation] Setting the cookie

Hi,
thanks for your work!
Actually, it's not an issue but something more related to the docs.

I'm trying to undertand how your process with authentification.
I see that in your security.yaml you don't configure any authentificator.

But in your webapp, you use the PHPSESSID cookie that is generated by Symfony. How do you do that? ^^

I don't understand very well GraphQL, but on login, i understand that you retrieve the user from your custom user provider but then it's quite mysterious.
In a second time, i understand that you set the cookie header (on the node server) based on the cookie the user have.

If you have any spare time, to explain this part a bit more, it would be very nice
Thank you

Improve file upload documentation

I think the file upload documentation is missing a few sample.

At the very end of the document, there is a simple Vue form to upload files, but you should probably also put here the GraphQL query and the PHP UseCase (and the Storable too).

That would really help understand how this works. Otherwise, you have to really now GraphQLite quite well to understand you can type-hint on a UploadedFileInterface.

Composer 2

^ from thecodingmachine Docker PHP images version 4.

Add link to files in documentation

Currently, there are no links for files in the documentation.

We should add these links so that user may access to the source code easily from the documentation.

Caution: links should be related to the current version of the documentation, not the master branch.

[V2][Front] Implement Rights and Roles Management

Description

We need to implement rights and roles management system that involves using the "page-ini-data" approach. This task encompasses conducting a (POC) and engaging in discussions.

Priority

Stop recommanding using ->graphqlField() in migrations?

In the Doctrine migration docs, we are recommanding putting "->graphqlField()" annotations directly in the schema.

See https://thecodingmachine.github.io/symfony-boilerplate/docs/database/doctrine-migrations

I think the whole "->graphqlField()" method was actually a mistake I made.
Because you cannot really add security annotations in the DB model. And therefore, by recommanding adding these annotations, we are pushing the developer into developing an insecure API.

Instead, we should recommand using a @SourceField annotation in the entity class. This is cleaner, easier to read (when you are looking for the list of fields of a class) and you can add security annotations in the SourceField annotation easily.

PHP 8

^ from thecodingmachine Docker PHP images version 4.

Add `buffer_size` to buffered log handlers

Issue

Long running process might go out of memory (OOM) if buffered log handlers are filled

while (true) {
    $this->bufferedLogHandler->info('test');
}

fingers_crossed is buffer based so it can run into this issue.

Fix

A buffer_size should be append to the config. This settings will tell the handler to keep only the nth most recent messages so this will avoid OOM.

The configuration doc can be found there (permalink)

A value of 100 should be far enough.

Voter with $user as argument

GraphQLite seems to have an issue when you uses $user as argument:

    /**
     * @Query
     * @Logged
     * @Security("is_granted('GET_USER', user)")
     */
    public function user(User $user): User
    {
        // ...
    }

Here the subject of the voter, user, is always equals to the authenticated user.

Workaround: rename the argument $user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.