Skip to content
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

Development mode (debug = true ) with CakePHP 3.0 #277

Open
mohinlakdawala opened this issue Jul 22, 2015 · 5 comments
Open

Development mode (debug = true ) with CakePHP 3.0 #277

mohinlakdawala opened this issue Jul 22, 2015 · 5 comments

Comments

@mohinlakdawala
Copy link

Hi,

The cache is not generated automatically even when debug value is set to 'true' with CakePHP 3.0 application. I have to manually generate the static files via the shell command everytime for every change.

Is there a way to avoid this ?

@markstory
Copy link
Owner

Set debug to false. There isn't a way to generate the static files on each request in debug mode. However, the development output is cached so that if input files do not change the development builder uses the cache for better performance. Why do you need the static files regenerated all the time?

@markstory markstory added this to the 3.0 milestone Jul 22, 2015
@markstory markstory modified the milestone: 3.0 Aug 31, 2015
@kevanescence
Copy link

Hi,

What should be the development configuration ?
Even setting debug to true and timestamp to true make javascript/css development very tedious.
I need to rebuild with the CLI tool each time I modify a file.

Did I misunderstand something ?

@markstory
Copy link
Owner

You shouldn't need to use the CLI tool in development mode. An example configuration that I have is

; Define an extension type.
; build targets are prefixed with this value
; are connected when the ini file is parsed.
[js]
paths[] = WEBROOT/js/*
cachePath = WEBROOT/cache/
filters[] = JsMinFilter

[css]
paths[] = WEBROOT/css/*
cachePath = WEBROOT/cache/

[app.js]
files[] = vendor/jquery-2.1.4.js
files[] = repos.js

[app.css]
files[] = base.css
files[] = cake.css

And in my config/bootstrap.php I have

Plugin::load('AssetCompress', ['bootstrap' => true]);

The debug option in the config file does nothing, instead you should debug in config/app.php of your application. When it is false, then you will need to use the CLI tool, but otherwise the files should automatically rebuild. You could be running into issues with the caching though. The plugin uses mtimes of files to skip building new assets for files that haven't changed.

@kevanescence
Copy link

Hi, sorry for long time response. Do not know if it is the right way to solve the problem but it seems to work.
I had a similar configuration than the above one.
Problem was: in the routes.php file, I commented line for InflectedRoute

    //$routes->fallbacks('InflectedRoute');

to specify explicitly my own routes.
Changed to something like

if (Configure::read('debug')) {
    Router::scope('/cache_js', function ($routes) {
        $routes->fallbacks('InflectedRoute');
    });
    Router::scope('/cache_css', function ($routes) {
        $routes->fallbacks('InflectedRoute');
    });
}

Note : if the css/js file is present in the webroot/cache_css and webroot/cache_js it will not be overwritten if the source file is modified. So in development mode those directories should by either empty or not present

@markstory
Copy link
Owner

Why do you need to define routes? This plugin doesn't use a controller and should be able to respond to URLs even if they have no routes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants