Nefungujici Use pri jednoduchych skriptech
- krogins
- Člen | 2
Zdravim, jsem v nette novy a nemohu zprovoznit ani jednoduchy skript..
sandbox/www/index.php
<?php
use Nette\Utils\Arrays;
$array = array("test1","test2","test3");
$value = Arrays::get($array, 'test1');
echo $value;
$value = arrays::get($array, 'test1', 'test');
echo $value;
sandbox/www/test.php
<?php
use Nette\Application\UI\Form;
class Wizard extends Contribute\FormWizard\Wizard {
protected function finish(): void
{
$values = $this->getValues();
}
protected function createStep1(): Form
{
$form = $this->createForm();
$form->addText('name', 'User name')
->setRequired();
$form->addSubmit(self::NEXT_SUBMIT_NAME, 'Next');
return $form;
}
protected function createStep2(): Form
{
$form = $this->createForm();
$form->addText('email', 'Email')
->setRequired();
$form->addSubmit(self::PREV_SUBMIT_NAME, 'Back');
$form->addSubmit(self::FINISH_SUBMIT_NAME, 'Register');
return $form;
}
}
?>
{
"name": "nette/sandbox",
"description": "The sandbox is a pre-packaged Nette Framework project, basic configured structure for your application.",
"homepage": "https://nette.org",
"type": "project",
"license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/en/contributors?lang=en"
}
],
"require": {
"php": ">=7.1",
"nette/application": "^3.0",
"nette/bootstrap": "^3.0",
"nette/caching": "^3.0",
"nette/database": "^3.0",
"nette/di": "^3.0",
"nette/finder": "^2.5",
"nette/forms": "^3.0",
"nette/http": "^3.0",
"nette/mail": "^3.0",
"nette/robot-loader": "^3.0",
"nette/safe-stream": "^2.4",
"nette/security": "^3.0",
"nette/utils": "^3.0",
"latte/latte": "^2.5",
"tracy/tracy": "^2.6",
"dg/adminer-custom": "^1.8"
},
"require-dev": {
"nette/tester": "^2.0"
},
"autoload": {
"classmap": ["app/Bootstrap.php"]
},
"minimum-stability": "dev",
"config": {
"platform": {
"php": "7.2"
}
}
}
web jede na Ubuntu 18.04
Apache2, php7.2-dev, zend, xdebug,
- neznamy_uzivatel
- Člen | 115
Do toho scriptu musíš nějak dostat ty knihovny, které používáš, tzn.
composer autoload / nette.
Používámm v cronech něco jako
<?php
use Nette\Utils\Arrays;
$container = require __DIR__ . '/../bootstrap.php';
// další služby si můžeš vytáhnout např.
/** @var \Nette\Database\Context $database */
$database = $container->getByType('\Nette\Database\Context');
$array = ["test1" => 'jedna', "test2" => 'dva', "test3" => 'tri'];
$value = Arrays::get($array, 'test1');
echo $value;
$value = Arrays::get($array, 'test1', 'test');
echo $value;
Editoval neznamy_uzivatel (6. 9. 2019 7:25)
- Kamil Valenta
- Člen | 822
Otázkou je, proč to chceš provozovat v samostatném skriptu, do kterého includuješ bootstrap. I prvotní test si udělej v presenteru, do kterého si předáš nějaký testovací model. Připadá mi lepší učit se věci rovnou tak, jak mají být.