forked from phalcon/cphalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
Submit Reproducible Test
Phalcon edited this page Mar 19, 2014
·
6 revisions
If you have found a bug it is important to add relevant information to allow us to reproduce the bug and fix it quicker.
A small single-file script is usually the best way to reproduce a problem:
$di = new Phalcon\DI\FactoryDefault();
//Register your custom services
$di['session'] = function() {
$session = new \Phalcon\Session\Adapter\Files();
$session->start();
return $session;
};
$di['cookies'] = function() {
$cookies = new Phalcon\Http\Response\Cookies();
$cookies->useEncryption(false);
return $cookies;
};
class SomeClass extends \Phalcon\DI\Injectable
{
public function someMethod()
{
$cookies = $this->getDI()->getCookies();
$cookies->set("mycookie", "test", time() + 3600, "/");
}
}
$c = new MyClass;
$c->setDI($di);
$c->someMethod();
$di['cookies']->send();
var_dump($_SESSION);
var_dump($_COOKIE);
Depending on your application type, you can follow these skeletons to reproduce the bug:
Remember to add to the script how you registered the database service:
$di = new Phalcon\DI\FactoryDefault();
$di->setShared('db', function () {
return new \Phalcon\Db\Adapter\PDO\Mysql(array(
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'dbname' => 'test',
'charset' => 'utf8',
));
});
$result = $di['db']->query('SELECT * FROM customers');
Remember to add to the script how you are creating the Phalcon\Mvc\Application instance:
$di = new \Phalcon\DI\FactoryDefault();
//other services
$app = new \Phalcon\Mvc\Application();
$app->setDi($di);
//register modules if any
echo $app->handle->getContent()
Follow this structure to create the script:
<?php
$di = new \Phalcon\DI\FactoryDefault();
$app = new \Phalcon\Mvc\Micro($di);
//define your routes here
$app->handle();