PHP: Installing minScript extension to Yii Framework - php

I have been debugging this for quite some time and am unable to find any solution - so this is my last hope.
I am trying to install/configure an extension for Yii called minScript by following this installation guide.
I place the extracted extension in my extensions folder, and change the config/main.php to the following:
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Demo app',
'controllerMap'=>array(
'min'=>array(
'class'=>'ext.minScript.controllers.ExtMinScriptController',
),
),
...
// application components
'components'=>array(
'clientScript'=>array(
'class'=>'ext.minScript.components.ExtMinScript',
'minScriptDebug'=>true,
),
...
Although when I try to run it, I get an error message:
CException
Alias "ext.minScript.components.ExtMinScript" is invalid. Make sure it points to an existing PHP file and the file is readable.
The file exists in the defined folder and is readable, yet the error message always appears.
Anyone have any idea what I am doing wrong?

If your installation is on Linux, be careful with spelling in file and directory names. I wasted a lot of time trying to solve the same problem with views and other components or extensions,
If not, try removing:
'minScriptDebug'=>true,
From your 'components' block.
Also assets and protected/runtime should be writtable (recursively).
Your file structure should look like:
protected/extensions/minScript/
components/
ExtMinScript.php
controllers/
ExtMinScriptController.php
vendors/...
minify/...
And finally maybe you have a trouble with urls, routing rules or with your .htaccess / web server setup. In first case, in config/main.php I use all the urls with format domain.com/site/parm1/parm2 and adding this before routing rules solved the trouble:
'urlManager'=>array(
'urlFormat'=>'path',
EDIT: I forgot this:
'controllerMap' section should be after 'components' in config/main.php,
Good luck!

Try insert before return (you need to declare alias ext - set it on extension directory):
Yii::setPathOfAlias('ext',
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'extension';

Related

Yii 1.1.16 : components folder is not accessible all over the application in Ubuntu

The error I'm getting is:
include(widgetHomeMenu.php): failed to open stream: No such file or directory
same for all other widget views I'm rendering on other pages.
The file is in my components directory. I guess the directory is not accessible because the file exists there. Plus I've given permission to all the files in /var/www.
Also in my config.php file, there is:
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
So, I guess the config is loading components as well.
Not sure where is the problem exactly. No problems with case sensitivity, its correct and the filename is correct as well. The application is working flawlessly on several Windows PC using xampp.
Will be thankful for any help.
I found the problem. It was ultimately related to case sensitivity even though I mentioned above that there was no such problem.
I was loading the widget like this:
<?php $this->widget('widgetDashboardMenu');?>
where I thought that widgetDashboardMenu was the name of the view that was about to render (my bad). This was actually the controller inside components named WidgetDashboardMenu which then loaded widgetDashboardMenu.
So, changing w to W solved the problem for me.
<?php $this->widget('WidgetDashboardMenu');?>

Arrange CakePHP plugins into subfolders

I've noticed some people mentioning a similar request for controllers and sometimes models, but I've been unable to find anything on arranging plugins in subfolders.
I want...
/app
/Plugin
/Modules
/Form
/Controller
/Gallery
/Controller
/SomeStandardPlugin
/Controller
..so that I can keep all the CMS functionality specific plugins separate.
I've tried:
CakePlugin::load('Form');
CakePlugin::load('Modules/Form');
CakePlugin::load('../Plugin/Modules/Form');
No matter which of the above I try, when I attempt to make use of the controller in one of the plugins, it says:
Error: FormsController could not be found.
Error: Create the class FormsController below in file: app\Controller\FormsController.php
(Which would be fine if I didn't want it in a plugin!)
The CookBook didn't mention anything about it either - is it just not supported or am I missing something?
FYI: I'm using CakePHP v2.2.3
The argument for CakePlugin::load is not a path
The first argument for this function, is the name of a plugin. This is the correct way to load a plugin:
CakePlugin::load('Name');
But it will only work if the plugin exists in a location configured using App::build
As such, to organize plugins into subfolders, it's necessary to declare all paths that contain a plugin:
// append app/Plugin/Modules to the path to look for plugins
App::build(array(
'Plugin' => array(
APP . 'Plugin/Modules'
)
));

Zend Framework 2 - Internal server error in module

I just created a module with a submodule like Backend\Entity1. I checked every path and namespace, they all seem to be ok.
I took out codeblocks one by one but stil I just get via Firebug a
"NetworkError: 500 Internal Server Error"
Any ideas what I can do to find the error?
I just don't know what might be wrong. Honestly, why does the framework explain itself what is happening? Its just fishing in the dark now...
BTW: The error.log doesn't show something either...
Edit:
I'm guessing that this error is raised because my app can't find the phtml files. Maybe I'm wrong but usually when I get this kind of silly error it has something to do with missing files...
My config code looks like this:
'view_manager' => array(
'template_path_stack' => array(
'entity' => __DIR__ . '/../view',
),
),
My namespace is MasterData\Entity and my add/edit/delete/index.phtml lie under view\masterdata\entity.
Any ideas how I can tell the TemplatePathStack how to look in this dir for my files?
If your want your sub module to be accessed create proper route in the parent module to make a way to access your sub module.
I IMHO if you need to create sub modules, create as module and place the modules under modules folder of your application, if you have components or third party modules place it under vendor folder.
This would be easier to manage at later stages an your url will also be much simpler
In my case, I created the new model in another way but I had the same error when I tried to see the result in the explorer. The problem (in my situation) was the access to files from the explorer, It resolves by changing files's permissions in linux's terminal.

how to use bootstrap with Yii?

I have been trying to implement twitter bootstrap extension in Yii but cannot do it.
I am following the guide below to install it with Yii.
http://www.cniska.net/yii-bootstrap/setup.html
I copied and pasted the following code in my main config file as described in above guide.
// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
return array(
'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
'modules'=>array(
'gii'=>array(
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
'components'=>array(
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
);
Can anyone please help.
Found the answer you need to put the following in your main.php file of your protected/views/layouts folder anywhere between <head> and </head> tag.
<?php Yii::app()->bootstrap->registerAllCss(); ?>
It worked for me like a piece of cake. I guess problem with you is your path to bootstrap extension. I would suggest to put complete path instead of relative path. Once it get working you can try to make the path relative.
Example:
Yii::setPathOfAlias('bootstrap', '/var/www/yoursite/application/extensions/bootstrap');
Instead of:
Yii::setPathOfAlias('bootstrap', dirname(FILE).'/../extensions/bootstrap');
This should work for you! Cheers!!!
I am also use that but the answer is not come but I got another way so you follow that I tell.
I think you want new themes so"
Go to download themes from yii framework.
Copy that folder then past to themes folder
config->main.php->'theme'=>'grey-stripes', protected go config folder go main.php go and copy 'theme'=>'grey-stripes',
Your new themes are ready

Running into couple of issues kohana framework: routing and running on ubuntu 12.04

I've started to learn kohana fews days ago and with my Zend Framework my learning experience seems to be fast until i run into couple of issues.
First of all i started the project in windows 7(dual booting with linux ubuntu 12.04). i know every link was fine before i started adding more pages to an admin app with kendo ui. i've added couple of routes to handle controllers in subfolders and to handle url with query string of the form ?bla=dkll&second=lkdjf (used by kendo grid to send unknown number of params based on users interaction with the grid).
First problem : under windows i would access any url except the root / eg localhost/admin/ (admin being my folder in htdocs) it gives me
ERROR: HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server :
83 try
84 {
85 if ( ! class_exists($prefix.$controller))
86 {
87 throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
88 array(':uri' => $request->uri()));
89 }
90
91 // Load the controller using reflection
92 $class = new ReflectionClass($prefix.$controller);
Second problem : Under ubuntu not only i have the same first problem but then i can't even hit other urls like localhost/admin/useraccess/login
Questions:
is the second problem related to the first one (obviously aside the '/' not found one)
i have enabled on ubuntu mod_rewrite and the kohana install page is all green.
is there any other settings i forgot to enable which was enabled in windows php (xampp) that's not on ubuntu?
my .htaccess/logs/boostrap are found here
thanks for reading this and helping out
I assume that root folder of your application is 'admin'. In bootstrap.php you should have:
Kohana::init(array(
'base_url' => '/admin',
'index_file' => FALSE,
));
Also in your bootstrap.php default route should be last route:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'index',
'action' => 'index',
));
Other routes that you add should take place above default route.
I have same problem with you, my kohana running well on my windows machine. but when i migrate it to Ubuntu I have a problem with routing. This is my bad, i forgot to edit my apache conf. You can look into conf file in /etc/apache2/sites-enabled/000-default
Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
/Directory>
edit 'AllowOverride None' to 'AllowOverride All' and restart your apache webserver .
Works like magic !!
To add to digby's note: All class file names and directory names are lowercase.
There are a few little things I noticed but nothing that could explain the problem you are having:
Query strings should not be and are not used to route to an action. Use $this->request->query() in controllers to use GET values.
Slashes get trimed off the beginning and end of URI's, so the optional / in the commented out 'def' route is useless.
The second time defining the kendogrid route overwrites the old one. Not that it really matters since they are the same, so why not remove one?
What controller do you expect to be routed too? Currently it should be Controller_... Hmm... I spy with my little eye a typo! 'susbcribers' instead of 'subscribers'. So currently you will be routed to Controller_Susbcribers::index().
If you want the Controller_Useraccess::index() instead of Controller_Subscribers::index() (assuming you fix the typo) remove the first kendogrid route since both 'kendogrid' and 'default' match an empty URI.
PS. I am assuming you use 3.2

Categories