Giter Club home page Giter Club logo

symfony-vuejs's Introduction

A new version with Symfony + GraphQL + Nuxt.js is available here: https://github.com/thecodingmachine/symfony-boilerplate


Source code of the tutorial thecodingmachine.io/building-a-single-page-application-with-symfony-4-and-vuejs.

Quick start

If you want to try out the project just follow those steps:

$ cp .env.template .env
$ docker-compose up -d
$ docker-compose exec app bash # executing bash inside app service
$ composer install
$ yarn install
$ yarn dev
$ php bin/console doctrine:migration:migrate
$ php bin/console doctrine:fixtures:load

On MacOS, also update your /etc/hosts file with:

127.0.0.1   app.localhost
127.0.0.1   phpmyadmin.app.localhost

You may now go to http://app.localhost/ and login using the following credentials:

Login: foo Password: bar

symfony-vuejs's People

Contributors

gulien avatar mrbig00 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony-vuejs's Issues

Symfony Plugin Configuration

Hi,
great work - thx for sharing.

I am using PHPStorm and use the Symfony Plugin, but I don't know how to configure the plugin when Symfony is not in root dir of the project, but in a sub dir.

symfony-vuejs-symfony-plugin-config

Greetings,
Dome

Impossible to try project : php bin/console doctrine:migration:migrate

Sorry i think it's simple to fix but i try everything on the docker compose file and it's impossible to get a correct access to database with symfony...
Even if i use the initial code of the repo without touching to the files i get this error.
phpmyadmin is working correctly but when i use doctrine to migrate tables from your files this error is throwed :

In AbstractMySQLDriver.php line 113:
An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory

I know 2002 error coming from a database issue but i don't find how to fix it.
I get the same error with fixture command.

Thanks for you help !

Async/await proposal

createPost ({commit}, message) {

Hi!
I would like to propose async/await approach.
There are some more lines of code and it looks more habitually (to me :) )

async/await version

actions: {
        async createPost ({commit}, message) {
            commit('CREATING_POST')
            try {
                const response = await PostAPI.create(message)
                commit('CREATING_POST_SUCCESS', response.data))
                return response.data
            } catch (err) {
                commit('CREATING_POST_ERROR', err)
                return null
            }
        },
      // ...
}

And some additional actions to make it work (async/await).

webpack.config.js

    .configureBabel(function(babelConfig) {
      babelConfig.plugins.push("@babel/plugin-transform-runtime");
    })

Babel 7

$ yarn add -D @babel/plugin-transform-runtime
$ yarn add -D @babel/runtime

package.json

{
 ...
    "browserslist": [
        "> 0.5%",
        "last 2 versions",
        "Firefox ESR",
        "not dead"
    ]
 ...
}

yarn dev Error

When I exec the command yarn dev in the container an error is throw :

WARNING   Webpack Encore requires version ^15.0.11 of vue-loader, but your version (14.2.3) is too old. The related feature will probably *not* work correctly.
 Error: Cannot find module 'vue-loader/lib/plugin'

trying to get it running without docker

When I try to get it running without docker, I get the following error: Environment variable not found: "DATABASE_URL".

My .env file looks like this:

KERNEL_CLASS=App\Kernel
APP_SECRET=s$cretf0rt3st
SYMFONY_DEPRECATIONS_HELPER=999999

DATABASE_URL='mysql://root:@localhost:3306/test'

I'm new to symfony and I can't figure out the problem.

JWT Auth

Hi, thanks for the example!
is it possible to switch authentication from JSON auth to JWT? maybe using lexik/LexikJWTAuthenticationBundle?

Thanks

Slow performance on MacOS

I have around 600ms response time for the /api/posts request (with docker-sync).
Looking for ways to improve this.

application/json needs to be handled on the ApiPostController.php

#I was having issues when submitted data to the backend, the controller was unable to get the message parameter. In order to process requests that have Content-Type: application/json header defined I added the following code on the ApiPostController.php file:

    /**
     * @Rest\Post("/api/post/create", name="createPost")
     * @param Request $request
     * @return JsonResponse
     * @IsGranted("ROLE_FOO")
     */
    public function createAction(Request $request): JsonResponse
    {
        // Added this in order to handle requests with Content-Type: application/json
        if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) {
            $data = json_decode($request->getContent(), true);
            $request->request->replace(is_array($data) ? $data : array());
        }
        $message = $request->request->get('message');
        $postEntity = $this->postService->createPost($message);
        $data = $this->serializer->serialize($postEntity, 'json');
        return new JsonResponse($data, 200, [], true);
    }

I don't know if this is the best way to do this, I'm new to Symfony.

BTW, thanks for creating this tutorial / guide was very helpful :)

plainPassword and password encoding

Hi!

In your code there is a line:

// necessary to force the update to see the change
$em->getUnitOfWork()->recomputeSingleEntityChangeSet($meta, $entity);

I don't quite understand what's the purpose of this code?

Also in a User entity you have method eraseCredentials(), but it never gets invoked. When should I use it?

Use .test TLD.

I would use app.test instead of the app.localhost. Chrome (tested on W10 Pro) will only go to 127.0.0.1 for *.localhost it appears. Worked fine in other browsers.

Feature Request : bind to multiple graphql endpoints

Actually, the package that provides GraphQL capabilities is not supporting multiple endpoints : see issue

We need this if :

  • we have multiple datasources,
  • when the same container can respond on multiple domain names (auth cookies will not be sent on different domains anymore)

A solution whould bo to define the GQL endpoint on the fly, but this doens't seem possible either with Gomah/nuxt-graphql-request

Symfony5 and API Platform

Terrific article (https://thecodingmachine.io/building-a-single-page-application-with-symfony-4-and-vuejs).

If you decide to update to Symfony 5 (which would be awesome), can you also consider using ApiPlatform instead of custom JSON endpoints?

Oh, if if you're feeling really generous with your time and talent, what about integrating Google's Workbox, and make this an offline SPA?

Question: if you were starting over, would you use Vue, or would you use React?

Anyway, thanks very much for your very thorough tutorial, much appreciated.

Use of wrapped PDO connection

This isn't so much as bug/issue as it is a discussion...

I'm trying to figure out why this project is using a wrapped Doctrine connection

- !service { class: PDO, factory: 'database_connection:getWrappedConnection' }

instead of allowing the PdoSessionHandler to create its own connection as suggested by the symfony docs
https://symfony.com/doc/4.4/session/database.html#store-sessions-in-a-relational-database-mariadb-mysql-postgresql

Can anyone shed light on this?

Frontend "theme" build

We should introduce how to build a "theme" with bootstrap and so on using Webpack Encore

Error handling

Improving error handling by:

  • displaying 500 error page
  • returning JsonResponse from backend exceptions.

No encoder has been configured for account "App\Entity\User".

php bin/console doctrine:fixtures:load

Эту команду надо выполнять уже после изменения файла config/packages/security.yaml ,
иначе это приводит к ошибке в заголовке

dependencies

I think you failed by adding these dependencies to the devDependencies:

yarn add --dev vue-router axios vuex

You should install them as a dependencies because you use them in your application, not only as a dev tools.

Remember me

Hello !

First : thank you for this tutorial, It is very helpfull to begin with vue with Sf

I have a question : how would you implement a remember me cookie ?

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.