Skip to content

Moved web assets to web/ and implemented a pure PHP compression solution for CSS and JS files #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CONTRIBUTING.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Contributing
============

The Symfony Demo application is an open source project. Contributions made by
the community are welcome. Send us your ideas, code reviews, pull requests and
feature requests to help us improve this project. All contributions must follow
the [usual Symfony contribution requirements](http://symfony.com/doc/current/contributing/index.html).

Web Assets Management
---------------------

This project manages its web assets in a special way to allow them to work
without configuring any option, installing any tool or executing any command.
If your contribution changes CSS styles or JavaScript code in any way, make
sure to regenerate the `web/css/app.css` and `web/js/app.js` files. To do so,
uncomment the Assetic blocks in the `app/Resources/views/base.html.twig` and
execute the following command:

```bash
$ php app/console assetic:dump --no-debug
```
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ $ cd symfony-demo/
$ php app/console server:run
```

This command will start a web server for the Symfony application. Now you can access
the application in your browser at <http://localhost:8000>. You can stop the built-in
web server by pressing `Ctrl + C` while you're in the terminal.
This command will start a web server for the Symfony application. Now you can
access the application in your browser at <http://localhost:8000>. You can
stop the built-in web server by pressing `Ctrl + C` while you're in the
terminal.

> **NOTE**
>
Expand Down
Binary file not shown.
Binary file not shown.
565 changes: 0 additions & 565 deletions app/Resources/assets/fonts/font-awesome/fontawesome-webfont.svg

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed app/Resources/assets/fonts/lato/Lato-Bold.woff
Binary file not shown.
Binary file removed app/Resources/assets/fonts/lato/Lato-BoldItalic.woff
Binary file not shown.
Binary file removed app/Resources/assets/fonts/lato/Lato-Italic.woff
Binary file not shown.
Binary file removed app/Resources/assets/fonts/lato/Lato-Regular.woff
Binary file not shown.
10 changes: 5 additions & 5 deletions app/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% block stylesheets %}
{# uncomment the following lines to compile SCSS assets with Assetic

{% stylesheets output="css/app.css"
{% stylesheets filter="scssphp" output="css/app.css"
"%kernel.root_dir%/Resources/assets/scss/bootstrap.scss"
"%kernel.root_dir%/Resources/assets/scss/font-awesome.scss"
"%kernel.root_dir%/Resources/assets/css/*.css"
Expand Down Expand Up @@ -133,10 +133,10 @@
{% endblock %}

{% block javascripts %}
{# uncomment the following lines to compile JavaScript assets with Assetic
{% javascripts output="js/app.js"
"%kernel.root_dir%/Resources/assets/js/jquery-2.1.4.min.js"
"%kernel.root_dir%/Resources/assets/js/bootstrap-3.3.4.min.js"
{# uncomment the following lines to combine and minimize JavaScript assets with Assetic
{% javascripts filter="?jsqueeze" output="js/app.js"
"%kernel.root_dir%/Resources/assets/js/jquery-2.1.4.js"
"%kernel.root_dir%/Resources/assets/js/bootstrap-3.3.4.js"
"%kernel.root_dir%/Resources/assets/js/highlight.pack.js" %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
Expand Down
8 changes: 4 additions & 4 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
sass:
bin: "/usr/bin/sass"
apply_to: "\.scss$"
jsqueeze: ~
scssphp:
# the formatter must be the FQCN (don't use the 'compressed' value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really ? for lessphp, using compressed works fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I use the following config:

assetic:
    filters:
        scssphp:
            formatter: 'compressed'

I get the following error:

assetic_error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz can you give the stack trace ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the full log information:

[2015-04-10 12:19:41] request.INFO: Matched route "homepage" (parameters: "_controller": "Symfony\Bundle\FrameworkBundle\Controller\TemplateController::templateAction", "template": "default/homepage.html.twig", "_route": "homepage") [] []
[2015-04-10 12:19:41] request.INFO: Matched route "_assetic_5c80c23_0" (parameters: "_controller": "assetic.controller:render", "name": "5c80c23", "pos": "0", "_format": "css", "_route": "_assetic_5c80c23_0") [] []
[2015-04-10 12:19:42] request.INFO: Matched route "_assetic_5c80c23_1" (parameters: "_controller": "assetic.controller:render", "name": "5c80c23", "pos": "1", "_format": "css", "_route": "_assetic_5c80c23_1") [] []
[2015-04-10 12:19:42] request.INFO: Matched route "_assetic_5c80c23" (parameters: "_controller": "assetic.controller:render", "name": "5c80c23", "pos": "null", "_format": "css", "_route": "_assetic_5c80c23") [] []
[2015-04-10 12:19:42] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted to load class "compressed" from the global namespace. Did you forget a "use" statement?" at /Users/javier/sf/symfony-demo/vendor/leafo/scssphp/src/Compiler.php line 129 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\ClassNotFoundException(code: 0): Attempted to load class \"compressed\" from the global namespace.\nDid you forget a \"use\" statement? at /Users/javier/sf/symfony-demo/vendor/leafo/scssphp/src/Compiler.php:129)"} []
[2015-04-10 12:19:42] request.INFO: Matched route "_assetic_5c80c23_2" (parameters: "_controller": "assetic.controller:render", "name": "5c80c23", "pos": "2", "_format": "css", "_route": "_assetic_5c80c23_2") [] []
[2015-04-10 12:19:43] request.INFO: Matched route "_assetic_5c80c23_3" (parameters: "_controller": "assetic.controller:render", "name": "5c80c23", "pos": "3", "_format": "css", "_route": "_assetic_5c80c23_3") [] []
[2015-04-10 12:19:43] request.INFO: Matched route "_assetic_5c80c23_4" (parameters: "_controller": "assetic.controller:render", "name": "5c80c23", "pos": "4", "_format": "css", "_route": "_assetic_5c80c23_4") [] []
[2015-04-10 12:19:43] request.INFO: Matched route "_wdt" (parameters: "_controller": "web_profiler.controller.profiler:toolbarAction", "token": "8282c1", "_route": "_wdt") [] []

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I want is the stack trace of the exception, not the logs (run your assetic dump command in verbose mode to get the stacktrace)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry! Here it is:

$ prod a:d -vvv
Dumping all prod assets.
Debug mode is off.

14:55:25 [file+] /Users/javier/sf/symfony-demo/app/../web/css/app.css
        /Users/javier/sf/symfony-demo/app/../web/assets/scss/bootstrap.scss
        /Users/javier/sf/symfony-demo/app/../web/assets/scss/font-awesome.scss
        /Users/javier/sf/symfony-demo/app/../web/assets/css/font-lato.css
        /Users/javier/sf/symfony-demo/app/../web/assets/css/highlight-solarized-light.css
        /Users/javier/sf/symfony-demo/app/../web/assets/scss/main.scss
[2015-04-10 14:55:25] php.EMERGENCY: Fatal Error: Class 'compressed' not found {"type":1,"file":"/Users/javier/sf/symfony-demo/vendor/leafo/scssphp/src/Compiler.php","line":129,"level":0,"stack":[]}



  [Symfony\Component\Debug\Exception\ClassNotFoundException]
  Attempted to load class "compressed" from the global namespace.
  Did you forget a "use" statement?



Exception trace:
 () at /Users/javier/sf/symfony-demo/vendor/leafo/scssphp/src/Compiler.php:129

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed. the ScssPhp library expects a class name. It is always nice to see consistency between libraries created by the same dev 😄

formatter: "Leafo\\ScssPhp\\Formatter\\Compressed"

# Doctrine Configuration (used to access databases and manipulate their information)
doctrine:
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"erusev/parsedown" : "~1.5",
"incenteev/composer-parameter-handler" : "~2.0",
"ircmaxell/password-compat" : "~1.0",
"leafo/scssphp" : "~0.1.",
"patchwork/jsqueeze" : "~1.0",
"sensio/distribution-bundle" : "~3.0.12",
"sensio/framework-extra-bundle" : "~3.0",
"symfony/assetic-bundle" : "~2.3",
Expand Down
109 changes: 103 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading