ZendDeveloperTools module not displaying a toolbar in ZF2 beta5 - module

I'm trying to install the ZendDeveloperTools modules for ZF2 beta5. Here are the steps I followed so far:
-Successfully installed ZendSkeletonApplication.
-Downloaded the module into my ./vendor directory.
-Enabled the module in ./config/application.config.php:
<?php
return array(
'modules' => array(
'Application',
'ZendDeveloperTools', // Added this line
),
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
'./module',
'./vendor',
),
),
);
-Copied ./vendor/ZendDeveloperTools/config/zenddevelopertools.local.php.dist to ./config/autoload/zenddevelopertools.local.php.
-Edited zenddevelopertools.local.php as follows:
<?php
return array(
'zdt' => array(
'profiler' => array(
'enabled' => true,
'strict' => true,
'verbose' => true,
'flush_early' => false,
'cache_dir' => 'data/cache',
'collectors' => array(),
'verbose_listeners' => array('application' => array(
'ZDT_TimeCollectorListener' => true,
'ZDT_MemoryCollectorListener' => true,
))
),
'toolbar' => array(
'enabled' => true,
'auto_hide' => false,
'position' => 'bottom',
'version_check' => false,
'entries' => array(),
),
),
);
-Added define('REQUEST_MICROTIME', microtime(true)); in my ./public/index.php
-Replaced my ./composer.json with the one provided in the ZendDeveloperTools module.
-Removed the , at the end of line 29 which was causing problems (shouldn't be there):
-Ran a composer update :
$ php composer.phar update
Updating dependencies
- Updating zendframework/zendframework (dev-master)
Checking out 9f4dd7f13c8e34362340072d0e2d13efe15e4b1f
Writing lock file
Generating autoload files
-Added error_reporting(E_ALL); ini_set('display_errors', '1'); to ./public/index.php to catch potential errors
When I access my application I don't get any errors (I get the skeleton application home page) but the zend developer toolbar isn't show up
What am I missing to make use of and display the zend developer toolbar?

It was a stupid mistake, I had placed zenddevelopertools.local.php into ./config and not ./config/autoload. Above instructions are correct. Here is what the toolbar looks like for those who are curious:

Worked for me, but one change I had to make for my app was rename the config from:
zenddevelopertools.local.php
to:
zenddevelopertools.local.config.php
Also, I installed BjyProfiler, which "just worked" with my Doctrine2 setup (nice!). The only caveat was that I had to add the default SM factory config so it would stop throwing errors:
'service_manager' => array(
'factories' => array(
/**
* This default Db factory is required so that ZDT
* doesn't throw exceptions, even though we don't use it
*/
'Zend\Db\Adapter\Adapter' => function ($sm) use ($dbParams) {
$adapter = new BjyProfiler\Db\Adapter\ProfilingAdapter(array(
'driver' => 'pdo',
'dsn' => 'mysql:dbname=skunk;host=hunk',
'database' => 'bunk',
'username' => 'junk',
'password' => 'punk',
'hostname' => 'lunk',
));
$adapter->setProfiler(new BjyProfiler\Db\Profiler\Profiler);
$adapter->injectProfilingStatementPrototype();
return $adapter;
},
),
),
See the screenshot:

Related

How can convert view page into a pdf in Yii

How can convert view page into a pdf in Yii from controller.
in main.php i added this code
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf' => array(
'librarySourcePath' => 'application.vendors.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class'=>'mpdf', // the literal class filename to be loaded from the vendors folder
),
'HTML2PDF' => array(
'librarySourcePath' => 'application.vendors.html2pdf.*',
'classFile' => 'html2pdf.class.php', // For adding to Yii::$classMap
)
),
),
Controller Code is
$mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
$mPDF1->WriteHTML($this->renderPartial('printformat', array(), true));
$mPDF1->Output();
Error : include(mpdf.php) [function.include]: failed to open stream: No such file or directory
The Error says, you have to include mpdf.php before using it.
You are using YiiPdf Bundle with html2pdf and mpdf.
First download Yii Pdf from here and include in extension as protected/extensions/yii-pdf (ext.yii-pdf as in 'class' => 'ext.yii-pdf.EYiiPdf',). This means your extension folder contains yii-pdf as directory.
Then, download mpdf from here. and place it in vendors as protected/vendors/mpdf as in
'librarySourcePath' => 'application.vendors.mpdf.*',
All explanation is here.

yii-user extension gives an invalid alias error

i'm new to yii and downloaded this extension
https://github.com/mishamx/yii-user
i've uploaded all the necessary files into the protected/ folder
but i keep getting this error. what am i missing?
Alias "user.UserModule" is invalid. Make sure it points to an existing PHP file and the file is readable.
/Applications/XAMPP/xamppfiles/htdocs/dev2/framework/YiiBase.php(322)
i edited my config/main/php which now looks like this
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// 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');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'my site',
'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.user.models.*',
'application.modules.user.components.*',
),
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class' => 'system.gii.GiiModule',
'password' => 'gii', //Enter Your Password Here
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters' => array('127.0.0.1','::1'),
'generatorPaths' => array('bootstrap.gii'),
),
'user'=>array(
# encrypting method (php hash function)
'hash' => 'md5',
# send activation email
'sendActivationMail' => true,
# allow access for non-activated users
'loginNotActiv' => false,
# activate user on registration (only sendActivationMail = false)
'activeAfterRegister' => false,
# automatically login from registration
'autoLogin' => true,
# registration path
'registrationUrl' => array('/user/registration'),
# recovery password path
'recoveryUrl' => array('/user/recovery'),
# login form path
'loginUrl' => array('/user/login'),
# page after login
'returnUrl' => array('/user/profile'),
# page after logout
'returnLogoutUrl' => array('/user/login'),
),
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'class' => 'WebUser',
),
'bootstrap' => array(
'class' => 'bootstrap.components.Bootstrap',
),
// uncomment the following to enable URLs in path-format
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
/*'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
),*/
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=DBNAME',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'admin#******.com',
),
);
?>
and this is my config/console.php file
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// preloading 'log' component
'preload'=>array('log'),
// application components
'components'=>array(
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=*****',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
),
),
),
'modules'=>array(
'user'=>array(
# encrypting method (php hash function)
'hash' => 'md5',
# send activation email
'sendActivationMail' => true,
# allow access for non-activated users
'loginNotActiv' => false,
# activate user on registration (only sendActivationMail = false)
'activeAfterRegister' => false,
# automatically login from registration
'autoLogin' => true,
# registration path
'registrationUrl' => array('/user/registration'),
# recovery password path
'recoveryUrl' => array('/user/recovery'),
# login form path
'loginUrl' => array('/user/login'),
# page after login
'returnUrl' => array('/user/profile'),
# page after logout
'returnLogoutUrl' => array('/user/login'),
),
)
);
if you are working with a linux enviroment, it's possible that your files do not have enough previlage to run files under users module directory.
try this to know if the problem is from here
chmod -R 777 /protected/modules/user/
not sure which version of yii-user you are using, but first download the latest version from here and follow the setting changes from that page too.
make sure you unzip all the files into protected/modules/user (NOTE: the modules and user folder doesn't exist so you will have to make one)
once done, insert items into zii.widgets.CMenu array (protected/views/layouts/main.php)
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),
I don't know why, but I had also same issue after I loaded last version of yiibooster 4.0.1 version my issue solved by changing all "bootstrap" aliases with "booster" in all part of my application.
As example
'bootstrap' => array(
'class' => 'ext.yiibooster.components.Bootstrap',
),
with
'booster' => [
'class' => 'ext.yiibooster.components.Booster',
],
Also don't forget to use filter methods in all actions:
public function filters(){
return [
'accessControl',
'postOnly + delete',
['booster.filters.BoosterFilter - delete'],
];
}

YII - define extracted bootstrap in config file

i'm new in Yii. and i'm using this LINK.
i'm extracted bootstrap on /blog/protected/extensions directory and define array into config/main.php like this:
//BOOT STRAP
'clientScript' => array(
'scriptMap' => array(
'jquery.js'=>false,
'jquery.min.js'=>false,
'core.css'=>false,
'styles.css'=>false,
'pager.css'=>false,
'default.css'=>false,
),
'packages'=>array(
'jquery'=>array(
'baseUrl'=>'bootstrap/',
'js'=>array('js/jquery.js'=>true /* SET AS DEFAULT*/ ),
),
'bootstrap'=>array(
'baseUrl'=>'bootstrap/',
'js'=>array('js/bootstrap.min.js',
'js/bootstrap-transition.js',
'js/bootstrap-alert.js',
'js/bootstrap-modal.js',
'js/bootstrap-dropdown.js',
'js/bootstrap-tab.js',
'js/bootstrap-tooltip.js',
'js/bootstrap-popover.js',
'js/bootstrap-button.js',
'js/bootstrap-collapse.js',
'js/bootstrap-carousel.js',
'js/bootstrap-typeahead.js',
'js/bootstrap-affix.js',
'js/holder.js',
'js/prettify.js',
'js/application.js',
),
'css'=>array(
'css/bootstrap.min.css',
'css/custom.css',
'css/bootstrap-responsive.min.css',
),
'depends'=>array('jquery'),
),
),
),
//BOOT STRAP
how to change 'baseUrl'=>'bootstrap/' to correct path of extension? this path does not work:
'baseUrl'=>'/protected/extensions/bootstrap/',
If you are new, learn about extensions.
Than download ready yii extension for bootstrap: Yii-Bootstrap or Yii-Booster.
You don't have to define any js package, bootstrap extension will do it for you.
Here is sample config part for yii-booster, which i use (actually for yii-bootstrap it should be same):
'components' => array(
// ... other components
'bootstrap' => array(
'class' => 'ext.bootstrap.components.Bootstrap',
'coreCss' => true,
'responsiveCss' => true,
'yiiCss' => true,
),
),
// .. other components
And thats it! Bootstrap will work.

yii-user-management install 404 error

I am using MAMP pro with yii-1.1.12. and I am trying to install the latest version of yii-user-management.
My route for the webapp is
/Users/myname/Sites/yii-1.1.12/htdocs
I created the 'modules' folder and copied the yii-user-management into it:
htdocs > protected > modules
(modules and subfolders set to rewrite)
config/main.php
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'password',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
'modules' => array(
'user' => array(
'debug' => true,
)
),
),
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'class' => 'application.modules.user.components.YumWebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('//user/user/login'),
),
'import'=>array(
'application.modules.user.models.*',
),
etc...
I have followed the instructions to the letter but when I call the user/install in the browser I get a 404 error.
http://yii.dev:8888/index.php/user/install
My page works okay http://yii.dev:8888/index.php/login (with or without index.php)
Very frustrating. Any help would be appreciated.
I just realized there's a problem with your config/main.php...
You have modules listed within modules:
'modules'=>array(
'gii'=>array(//...gii configuration...),
'modules' => array(
'user' => array(
'debug' => true,
)
),
It should just be:
'modules'=>array(
'gii'=>array(//...gii configuration...),
'user' => array(
'debug' => true,
)
),

YII URLManager for RESTfull API

Trying to work on a RESTfull API with yii (being the first project using yii)
Having problem with getting URLManager to properly route calls:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
'api/<controller>' => array('api/<controller>/list', 'verb' => 'GET'),
'api/<controller>' => array('api/<controller>/create', 'verb' => 'POST'),
),
),
Tried working with this (this is not the full snippet, I had dispatchers for PUT/DELETE etc..
But it did not work... Being desperate, I tried even something as simple as that:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
'tezt' => array('landing/beta', 'verb' => 'GET'),
'tezt' => array('landing', 'verb' => 'POST'),
),
),
whenever I remove one of the rules, it works, but when I put both the rules in, none of them works, I get exception
exception.CHttpException.404
exception 'CHttpException' with message 'Unable to resolve the request
"tezt".' in /yii-1.1.10/web/CWebApplication.php:280
Been banging my head agains this for 2 days now. Probably seen all the samples and tutorials on URLManager on the web (although could not find a straightforward and complete explanation of the rules). But, no joy.
Am I doing something wrong? Is it my box setup maybe?
I tried this and it worked:
'rules'=>array(
//API URLs
array('api/<controller>/index', 'pattern'=>'api/<controller:\w+>', 'verb'=>'GET'),
array('api/<controller>/create', 'pattern'=>'api/<controller:\w+>', 'verb'=>'POST'),
array('api/<controller>/view', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'GET'),
array('api/<controller>/update', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'PUT, POST'),
array('api/<controller>/delete', 'pattern'=>'api/<controller:\w+>/<id:\d+>', 'verb'=>'DELETE'),
//Other URLs
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
"api" is a module configured in modules section as
'api'=>array('defaultController' => 'default',),
In REST client, you have to specify controller name, even for default controller.
I am using Yii 1.1.10 but I think Yii supports RESTful URLs since 1.1.7.
try this
'api/<controller:\w+>' => array('api/<controller>/list', 'verb' => 'GET'),
is api a module?
For anyone else who stumbles on this, it didn't work because the rules were declared using the same keys, so the latter rule overrode the former.
In the future, declare the pattern in the rule configuration array:
array(
'route',
'pattern' =>'somePattern',
'verb' =>'...',
),
array(
'another/route',
'pattern' =>'anotherPattern',
'verb' =>'...',
),