AssetCompress for CakePHP 1.3 - cakephp

I'm using AssetCompress v0.5 from the 1.3 branch and the dynamic built is not working. I've done the following so far:
Downloaded and copied the asset_compress folder into my app/plugins folder
Copied the config.ini and renamed it to app/config/asset_compress.ini
Created 2 CSS and JS bundles named public and logged (so 4 in total)
Added AssetCompress.AssetCompress in my $helpers array in my AppController
Changed my default.ctp layout file to: echo $this->AssetCompress->css('public'); echo $this->AssetCompress->css('logged'); (same for ->script())
The output error is:
Error: The requested address '/asset_compress/assets/get/public.css' was not found on this server.
What am I missing?

Ok, I figured it out.
It was because I was using the CssMin filter and I did not download it and put it into the vendor folder. As the plugin seems to be turning the debug level to 0, I did not see the error, until I put a Configure::write('debug', 2); into the beforeFilter().

Related

WAMP doesn't refresh files

I've been working with WAMP for 2 years now and it's the first time I got this problem. I created a new website base with Symfony, and now I'm adding some files to it in Windows (by creating a bundle in a console) but it doesn't appear in the browser in localhost even I refresh it, so when I go in /web, I got those errors like these :
( ! ) Fatal error: Uncaught Error: Class 'SNS\PlatformBundle\SNSPlatformBundle' not found in D:\wamp\www\sns_symfony\sns_symfony\app\AppKernel.php on line 20
( ! ) Error: Class 'SNS\PlatformBundle\SNSPlatformBundle' not found in D:\wamp\www\sns_symfony\sns_symfony\app\AppKernel.php on line 20
Call Stack
# Time Memory Function Location
1 0.0010 385736 {main}( ) ...\app.php:0
2 0.0070 418000 AppKernel->handle( ) ...\app.php:19
3 0.0070 418000 AppKernel->boot( ) ...\Kernel.php:195
4 0.0070 418000 AppKernel->initializeBundles( ) ...\Kernel.php:132
5 0.0070 417952 AppKernel->registerBundles( ) ...\Kernel.php:492
Can someone help me please ? ^^'
I'll explain myself more. I used the bundle generator of Symfony so I dind't write anything, juste used the console. By the way there is some folders that WAMP can't see (I don't see them in the browser in localhost) and the file he's looking for are in those folders he can't see. There is the problem.
First of all, double check if the bundle really exists on your hard drive. You're on Windows, so just go to D:\wamp\www\sns_symfony\sns_symfony\src and check if there's a PlatformBundle\SNSPlatformBundle.php in your src dir. If not - now you know the generator didn't generate anything. Maybe accidentally aborted?
Then check if you have right PSR-0 or PSR-4 (most likely ) namespace in your composer.json file. You can run php composer validate to see warnings.
And as the last step run composer dump-autoload which updates the autoload file
Finally I found the solution after hours of deeps researches. Here it is :
Create the bundle
Edit your app/config/config.yml file like (add templating: engines ['twig'] in framework:)
framework:
templating:
engines: ['twig']
Thanks for help people ! :D
SOLVED !

Cakephp 3 - Plugin - translation file - not working

Using Cake version 3.4.5 :
1) I've wrote a plugin :
/plugins/Accounting/
2) then, to create the pot file from the view files I run :
bin/cake i18n extract --plugin Accounting
3) this generates /plugins/Accounting/src/Locale/default.pot
But the translated text does not appear.
My locale is es_AR, and I've tried to copy the file as :
/plugins/Accounting/src/Locale/accounting.pot
or
/plugins/Accounting/src/Locale/es_AR/default.pot
or
/plugins/Accounting/src/Locale/es_AR/accounting.pot
Also tried to save the files as accounting.po, but nothing happens
But still not text is translated from the plugin views (it does work for the app's views).
I've found it !!!
The problem was the file / directory permissions.
By default, cake i18n extract --plugin MyPlugin makes this :
creates the src/Locale/ directory inside the plugin structure
creates the template translation file default.pot instead of
my_plugin.pot
all these creations are made with mode 750 being
the owner the linux user currently logged in ( not www-data )
So in order to make it work :
change the permissions of the Locale structure to 755
rename default.pot to my_plugin.po
use __d( 'my_plugin', 'Text to be translated' )

Copy static files from one Jekyll post to published site

I would like to copy any static file (image, PDF, etc.) found in a post folder inside _posts to the folder in which the HTML version of the post will be, inside _site.
Let's say I have this structure:
_posts/
2016/
06/
09-so-long-cloudflare/
2016-06-09-so-long-cloudflare-and-thanks-for-all-the-fissh.md
cloudflare-logo.png
performance-report-sample.pdf
My Jekyll settings for permalinks are:
# Permalinks
permalink: /:year/:month/:day/:title/
I would like to generate the site like this:
2016/
06/
09/
so-long-cloudflare-and-thanks-for-all-the-fissh/
index.html
cloudflare-logo.png
performance-report-sample.pdf
I've found this plugin that should do this, but I can't make it work. I get this error:
jekyll 3.1.6 | Error: undefined method `name' for #<Jekyll::Document:0x007fb7a0892b50>
Any idea?
Thanks!
Well, despite having no Ruby knowledge, I managed to build a plugin out of this old Gist! \o/
https://nhoizey.github.io/jekyll_post_files/
I hope this will help people with the same needs.

CakePHP 2.1 new install Missing Controller Error

I am completely new to CakePHP and installed 2.1. I am getting this error:
Missing Controller
Error: Index.phpController could not be found.
Error: Create the class Index.phpController below in file: app\Controller\Index.phpController.php
<?php
class Index.phpController extends AppController {
}
Notice: If you want to customize this error message, create app\View\Errors\missing_controller.ctp
Stack Trace
APP\webroot\index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
ROOT\index.php line 40 → require(string)
I followed their guide at http://book.cakephp.org/2.0/en/installation/advanced-installation.html and tried everything it stated:
I enabled mod_rewrites (they were already enabled from something else)
I have all the .htaccess files in the directories
I have cake installed under my document root so I access it at localhost/cakephp/index.php
I do not know where to proceed from here. Thanks for any help you can give me.
Update: I just re-read your question and realized you're loading http://localhost/cakephp/index.php. Don't do that. Since you appended "index.php", it is trying to load a controller called "index.php" and the action "index" for that controller. Resulting mapped path to the "index.php controller" is app\Controller\Index.phpController.php.
Since you have the rewrites enabled, browse to http://localhost/cakephp without appending any filename.
Original answer:
Assuming you're using Apache, double-check the .htaccess in your /app/webroot directory. It should include the following:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Based on your error, it doesn't look like it's properly appending the path after your index.php file.
If you are using cakephp 2.0 or greater than rename the controller file name as the class name.
ie TaskController.php
class TasksController extends AppController {
--Your code inside class
}
I hope this will help you
the easiest solution is to stick to the "live environment" as close as possible.
this means using vhosts to use a "domain" and correctly root down to your webroot dir:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
this leaves almost no room for error and also helps with other potential problems like "absolutely linked asset files" etc

relative URLs in cakePHP

I am using cakePHP 1.26 and TinyMCE v3.38.
The .js file of the TinyMSC is stored under this directory:
http://www.mysite/js/tiny_mce/tiny_mce.js
In the page where the users can post new topic,
the URL of this page is like this:
http://www.mysite/user/newpost
Now I need to add the javascript to this page, and I have tried these:
echo $javascript->link('/js/tiny_mce/tiny_mce.js');
echo $javascript->link('js/tiny_mce/tiny_mce.js');
echo $javascript->link('../js/tiny_mce/tiny_mce.js');
But the tiny_mce.js can not be reached.
I believe that Cake already knows that your javascript is in /js/ through using the $javascript->link() structure in the first place - so try
echo $javascript->link('tiny_mce/tiny_mce.js');
and see if you get anywhere.

Resources