pug-php / pug-symfony

Pug (Jade) template engine for Symfony

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pug with Symfony is not working at all

dudematthew opened this issue · comments

After following instructions with following steps:

  1. Installing Symfony
  2. Installing pug-symfony
  3. Installing annotations
  4. Copying template and controller content to my project

Still, even with .pug extension, Symfony is translating template using Twig, not Pug.

image

I seem to have tried every possible way, but with no effect.

What am I doing wrong? isn't it a bug?

commented

I can confirm there is a regression in a recent version of Symfony making pug-symfony incompatible. Precisely a renaming of the Twig environment we override to enable pug support. I'm investigating how we could handle this change.

commented

Please try to clean your cache (rm -rf app/cache/*) then update to get the new pug-symfony version 3.1.0:

composer update

You should now see .pug files properly rendered.

Please let me know if updating fixed it or if you got any trouble.

Thank you for your reply.

After following your proposition and executing following code:

PS C:\Users\Mateusz\Desktop\Symfony Pug test> composer update
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "5.2.*"
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.
Generating optimized autoload files
Package added to be installed/updated with npm: jstransformer@"^1.0.0"
Package added to be installed/updated with npm: coffee-script@"*"
Package added to be installed/updated with npm: less@"*"
Package added to be installed/updated with npm: clean-css@"*"
Package added to be installed/updated with npm: babel-cli@"^6.10.1"
Package added to be installed/updated with npm: babel-plugin-transform-react-jsx@"^6.8.0"
Package added to be installed/updated with npm: babel-preset-es2015@"^6.8.0"
Package added to be installed/updated with npm: babel-preset-react@"^6.11.1"
Package added to be installed/updated with npm: stylus@"*"
Package added to be installed/updated with npm: uglify-js@"*"
Package added to be installed/updated with npm: clean-css@"*"
Package added to be installed/updated with npm: pug-cli@"^1.0.0-alpha6"
Packages installed.
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
89 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Synchronizing package.json with PHP packages
Don't forget to run npm install --force or yarn install --force to refresh your Javascript dependencies!
Run composer recipes at any time to see the status of your Symfony recipes.

Executing script assets:install public [OK]

Everything stays the same. Should I upload this test project to a repository and share it?

commented

As per your output, composer did not download pug-symfony 3.1.0. You probably need to clear the composer cache, then don't forget to clear the Twig cache too, so full steps are:

rm -rf var/cache/*
composer clearcache
composer update

I've followed these steps. There is no cache folder in app to clear.

After clearcache output of update is the same as last one.

Here is my composer.json:

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "1.11.99.1",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.2",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.8",
        "phpdocumentor/reflection-docblock": "^5.2",
        "pug-php/pug-symfony": "^3.0",
        "sensio/framework-extra-bundle": "^5.6",
        "symfony/asset": "5.2.*",
        "symfony/console": "5.2.*",
        "symfony/dotenv": "5.2.*",
        "symfony/expression-language": "5.2.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.2.*",
        "symfony/framework-bundle": "5.2.*",
        "symfony/http-client": "5.2.*",
        "symfony/intl": "5.2.*",
        "symfony/mailer": "5.2.*",
        "symfony/mime": "5.2.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "5.2.*",
        "symfony/process": "5.2.*",
        "symfony/property-access": "5.2.*",
        "symfony/property-info": "5.2.*",
        "symfony/security-bundle": "5.2.*",
        "symfony/serializer": "5.2.*",
        "symfony/string": "5.2.*",
        "symfony/translation": "5.2.*",
        "symfony/twig-bundle": "^5.2",
        "symfony/validator": "5.2.*",
        "symfony/web-link": "5.2.*",
        "symfony/yaml": "5.2.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "symfony/browser-kit": "^5.2",
        "symfony/css-selector": "^5.2",
        "symfony/debug-bundle": "^5.2",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^5.2",
        "symfony/stopwatch": "^5.2",
        "symfony/var-dumper": "^5.2",
        "symfony/web-profiler-bundle": "^5.2"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*"
    },
    "scripts": {
        "auto-scripts": {
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.2.*"
        }
    }
}
commented

I confirm I could reproduce the bug and it rendered Pug again after updating the package.

Please first check your version:
composer show pug-php/pug-symfony

If it does not show versions : * 3.1.0 and you still get Nothing to install, update or remove when you run composer update (double-check you use update and not install which takes first your composer.lock), then you have a composer cache to clean as the version is properly published on https://packagist.org/packages/pug-php/pug-symfony

Last, about the Twig cache, I mistaken the directory in my previous post, it's rm -rf var/cache/* (var instead of app).

Thank you very much for your help!

Running rm -rf var/cache/* >> composer update solved the problem. Now I can continue with using my favourite template for my project :)

Have a nice day!