symfony

Command "encore" not found when trying yarn encore dev command

I am currently stuck at the Encore/Webpack installation. I followed the steps at symfony.com. But when continuing to the simple example I got stuck at running yarn encore dev. I get the error: “Command “encore” not found”. I also have an error when running symfony server:start after installing Encore and navigating to a view:

An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "path/entrypoints.json" does not exist.").

As far as I know the entrypoints.json should have been autogenerated. I have Yarn 1.22.10 and NodeJS 6.14.12.

What I have done

I executed the commands composer require symfony/webpack-encore-bundle
and yarn install

  1. I looked at StackOveflow questions ‘error Command “encore” not found.’ when running ‘yarn run encore’ in Symfony4, webpack encore dev-server not found /, Error Command “encore” not found. (separate backend webpack), Can’t run encore dev
  2. I executed the command composer require webpack
  3. I noticed my package.json doesn’t have a scripts object where the command encore dev is supposed to be living. I watched a YouTube video and followed it (https://youtu.be/Fs_4FMoSO90). That’s why I know this. I wonder why I don’t have it. Below is the package.json from the video. My package.json only has the dev dependency Bootstrap.
  4. Executed npm install

Package.json from video:
the package.json from the video

My package.json:

{
  "devDependencies": {
    "bootstrap": "^5.0.0"
  }
}

I removed the package.json, package-lock.json and executed yarn install again and it installed some packages. I didn’t need NPM. I already got Bootstrap from my Yarn.lock (that’s the only thing in there). I still have both errors though.

Prefill checkbox in symfony

I have a user entity, with a field isSubscribed.
I want to show the status of this (boolean) as a checked or unchecked checkbox in a form.
Normally I would get this value in my formtype from a query but that seems overkill.
I want to do so…