nefunkcne pripojenie k db
- master69
- Člen | 4
Zdravim
Snazim sa zacat s nette, ale mam stale ten isty problem. Viem, ze to tu bolo vela krat riesene, ale aj tak sa mi nepodarilo problem odstranit.
Kvoli tutorialu som si stiahol verziu Nette Framework 0.9.7 pro PHP 5.2 + dibi 1.5-rc1. Bootstrap.php a config.ini som vytvoril podla navodu.
bootstrap.php
<?php
/**
* My Application bootstrap file.
*
* @copyright Copyright (c) 2010 John Doe
* @package MyApplication
*/
// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
require LIBS_DIR . '/Nette/loader.php';
// Step 2: Configure environment
// 2a) enable NDebug for better exception and error visualisation
NDebug::enable(NDebug::DETECT, APP_DIR . '/../log/error.log');
// 2b) load configuration from config.ini file
NEnvironment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = NEnvironment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new NRoute('index.php', array(
'presenter' => 'Homepage',
'action' => 'default',
), NRoute::ONE_WAY);
$router[] = new NRoute('<presenter>/<action>/<id>', array(
'presenter' => 'Homepage',
'action' => 'default',
'id' => NULL,
));
Environment::setName( 'production' ); //tímto musí být nastaven blok, který se načte z configu
Environment::loadConfig();
dibi::connect(Environment::getConfig('database'));
// Step 5: Run the application!
$application->run();
config.ini
;
; SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
; https://nette.org/en/security-warning
;
[common]
; PHP configuration
php.date.timezone = "Europe/Prague"
; variables
variable.tempDir = %appDir%/temp
variable.logDir = %appDir%/log
; services
service.Nette-Security-IAuthenticator = Users
service.Nette-Loaders-RobotLoader.factory = Nette\Configurator::createRobotLoader
service.Nette-Loaders-RobotLoader.option.directory[] = %appDir%
service.Nette-Loaders-RobotLoader.option.directory[] = %libsDir%
service.Nette-Loaders-RobotLoader.run = TRUE
[production < common]
; common database connection
database.driver = mysql
database.database = ######
database.charset = utf8
database.lazy = TRUE
database.host = localhost
database.username = ######
database.password = #####
[development < production]
; database options in development mode
database.profiler = TRUE
database.username = #####
database.password = ####
Ale stale mi hlasi tu istu chybu.
Cannot instantiate service ‚Nette\Loaders\RobotLoader‘, handler ‚Configurator::createRobotLoader‘ is not callable.
Tu na fore, som nasiel temu s podobnym problemom ale riesenie zmenit:
service.Nette-Loaders-RobotLoader.factory = Nette\Configurator::createRobotLoader
na
service.Nette-Loaders-RobotLoader.factory = Nette\NConfigurator::createRobotLoader
mi vyhodi chybu : Fatal Error
Class ‚NDirectoryNotFoundException‘ not found
Viete mi prosim Vas poradit , ako problem odstranit?
- master69
- Člen | 4
Zdravim ziadna zmena po vysipani kes. Nakonec som si stiahol verziu 2.0 pre php5.3
A upravil som bootstrat.php, config.neon podla :
"":https://forum.nette.org/…di-container#…
Ale tentokrat my hadze chybu:
Set path to temporary directory using setCacheDirectory().
- Ot@s
- Backer | 476
Tak jinak, koukni se a inspiruj se třeba na https://github.com/…e-quickstart a https://github.com/nette/sandbox. Sice k tomu neexistuje konkrétní dokumentace, jedná se ale o nejjednodušší použití Nette, takže je to hodně čitelné.
K chybě, kterou řešíš – v app/bootstrap.php ti chybí řádek
// Configure application
$configurator = new Nette\Config\Configurator;
$configurator->setCacheDirectory(__DIR__ . '/../temp'); // <-tento radek