Nette Framework 2.2 beta released
- David Grudl
- Nette Core | 8218
I'd like to announce the Nette Framework 2.2, the biggest revolution in its history.
Nette has been split into small projects Application, Bootstrap, Caching, ComponentModel, Nette Database, DI, Finder, Forms, Http, Latte, Mail, Neon, PhpGenerator, Reflection, RobotLoader, SafeStream, Security, Tokenizer, Tracy and Nette Utils.
It also brings complete new Latte API for standalone usage:
$latte = new Latte\Engine;
$latte->setTempDirectory('/path/to/cache');
$latte->addFilter('money', function($val) { return ...; }); // formerly registerHelper()
$latte->onCompile[] = function($latte) {
$latte->addMacro(...); // when you want add some own macros, see http://goo.gl/d5A1u2
};
$latte->render('template.latte', $parameters);
// or $html = $latte->renderToString('template.latte', $parameters);
Also Nette\Diagnostics was renamed to nice and short Tracy.
You can, as usual, download complete
package Nette 2.2 beta1 or install it via Composer with
minimum-stability
sets to beta
:
"require": {
"nette/nette": "~2.2.0"
},
"minimum-stability": "beta"
Release RC1
- added some deprecation warnings for 2.0.x users
- removed some proxy classes and replaced with class aliases
- Tracy: added support for old CSS classes in Nette\Diagnostics panels
- DI: inject is disabled by default
- DI: reverted support for factories in addService()
- Latte & Templating: much improved compatibility
- DI: added old latte & template services; and nette.latte.macros configuration
- Reflection: removed support for own annotation classes
- Tracy: uses own file for logging exceptions
Released RC2
- added deprecated method Nette\Diagnostics\Helpers::textDump(), htmlDump() and clickableDump()
- Tracy: class .tracy-toggle-collapsed changed to .tracy-toggle.tracy-collapsed
- Nette\Latte\Engine registers Form macros early to allow override them
- Nette\Latte\Engine supports accessing compiler and parser via property
- Nette\Templating\Template uses Nette\Latte\Engine
- important class aliases are created always (even with Composer)
- removed NetteLoader::createAliases() (BC break)
- fixed some bugs with undefined macros in Latte
Released RC3
- Configurator & NetteExtension moved to Bootstrap
- renamed internal Nette\Bridges\Framework\ILatteFactory to Nette\Bridges\ApplicationLatte\ILatteFactory
- Neon moved to namespace Nette\Neon (class Nette\Utils\Neon still works)
- fixed some compatibility issues with Latte & Tracy
- Nette\Utils\DateTime::createFromFormat() returns instance of the same class
- Nette\Utils\Html encodes array in data- attributes as JSON
Released RC4
- Nette Loader works with Composer
- David Grudl
- Nette Core | 8218
I mentioned Routing in the list by mistake. Routing is currently experimental project.
- David Grudl
- Nette Core | 8218
If you want to watch all the commits from all repositories, you may find useful this pipe http://pipes.yahoo.com/pipes/pipe.info?….
- RadaR
- Member | 46
I have problem with running example for standalone Latte API. Topic moved https://forum.nette.org/…et-not-found#…
Last edited by RadaR (2014-04-09 09:57)
- Milo
- Nette Core | 1283
I deployed 2.2-rc1
instead of 2.1.1 on one bigger internal
website and there is a report.
Template::registerHelperLoader() is deprecated, use dynamic getLatte()->addFilter()
.
To help understand new API I would hint:
...registerHelperLoader($callback) is deprecated ... getLatte()->addFilter(NULL, $callback)
.
I'll open PR.
EDIT: Misleading, see issue
Source code in Tracy is not collapsed as used to be. I mean deprecated error
shows path to trigger_error()
in Nette source but not to user code
e.g. BasePresenter. Maybe it is my feeling only.
FATAL: Nette\Latte\Macros\MacroSet not found
is related to Nette issue I guess.
Maybe dtto.
Latte\CompileException: Unknown macro {label} in ...
I had to
add:
Nette\Bridges\FormsLatte\FormMacros::install($engine->getCompiler());
It is in one of mine component where I'm creating template manually, not presenter.
LogicException: Latte\Engine::$compiler: Cannot read undeclared property
I used $engine->compiler
with old Latte,
$engine->getCompiler()
solves the problem. I'll open PR to
handle few old getters/setters with deprecated error.
Fatal Error: Class 'Nette\Latte\Macros\FormMacros' not found
Whole this thing is my very old version of manual form rendering. I guess it can be solved as mentioned Nette issue but I solved it directly:
Old code:
$macroSet->addMacro('form',
'Nette\Latte\Macros\FormMacros::renderFormBegin($_form, %node.array)',
'Nette\Latte\Macros\FormMacros::renderFormEnd($_form)'
);
New code:
$macroSet->addMacro('form',
'Nette\Bridges\FormsLatte\FormMacros::renderFormBegin($_form, %node.array)',
'Nette\Bridges\FormsLatte\FormMacros::renderFormEnd($_form)'
);
At all, I have not problems with migration.
Last edited by Milo (2014-04-22 14:04)
- David Grudl
- Nette Core | 8218
Source code in Tracy is not collapsed
Yes, source code is collapsed only for exceptions. Maybe it can be collapsed for E_USER_DEPRECATED too.
FATAL: Class not found
This is annoying :-( For some classes we can (re)create fake classes, but for some of them we need to create alias (because they can be used with instanceof).
What about this solution? https://github.com/…2718dfb01a7f
Unknown macro {label}
That's right, I added old Nette\Latte\Engine
here https://github.com/…e39e8c6dc8b6#…
which registers all macros.
- Milo
- Nette Core | 1283
I tried migration once again with:
"require": {
"nette/nette": "2.2.*",
},
"minimum-stability": "dev"
so I'm on commit 3839d7.
I hit the problem with macro redefining. I have a form component which uses latte for rendering self. In a short:
class LatteForm extends Nette\Application\UI\Form
{
public function getTemplate()
{
$engine = new Nette\Latte\Engine;
$macroSet = new Nette\Latte\Macros\MacroSet($engine->compiler);
// redefine {form ...} macro
$macroSet->addMacro('form',
'Nette\Latte\Macros\FormMacros::renderFormBegin($_form, %node.array)',
'Nette\Latte\Macros\FormMacros::renderFormEnd($_form)'
);
$template = new Nette\Templating\FileTemplate;
$template->registerFilter($engine);
$template->_form = $this;
}
}
When rendered I get following error, because old {form}
macro
is not rewritten.
Missing form name in {form}
I guess it is because of some class_alias()
or empty class
combinations, but I didn't find it. When I switch namespaces form
Nette\Latte
to new Latte
only, I must:
# rewrite
$engine->compiler
# to
$engine->getCompiler()
# and add
Nette\Bridges\FormsLatte\FormMacros::install($engine->getCompiler());
Now it works perfectly in old way.
EDIT: And with aliases.php is the migration more comfortable.
Last edited by Milo (2014-04-23 10:47)
- mrtnzlml
- Member | 140
There is still problem with Nette\ObjectMixin
. For example
EntityManager from Kdyby causes Fatal Error in method __call
:
<?php
public function __call($name, $args) {
return Nette\ObjectMixin::call($this, $name, $args);
}
?>
Next problem is with class Nette\Templating\ITemplate
. Can't use
instanceof in tests…
Last problem is with method
Nette\Diagnostics\Helpers::clickableDump()
. It doesn't exist
anymore (?). (Kdyby\Events)
Not sure if it's problem of framework or extensions, but it is not without BC breaks.
- David Grudl
- Nette Core | 8218
Milo: can you test it with https://github.com/…e4666ad6eba4
mrtnzlml: clickableDump() has been added. What Fatal Error causes __call?
- Milo
- Nette Core | 1283
I tried to migrate on 2.2-RC2. The only error I get is:
Fatal Error
Class 'Nette\Latte\Macros\FormMacros' not found
It can be solved by:
class_alias('Nette\Bridges\FormsLatte\FormMacros', 'Nette\Latte\Macros\FormMacros');
After that, I get deprecated notices only.
And I tried to migrate one smaller website from Nette 2.0.8 directly to 2.2-RC2. I had to remove sections from config and it works perfectly.
- David Grudl
- Nette Core | 8218
Milo: I have added this class to NetteLoader. But I suppose you are using Composer, so it is question whether Composer should create Nette Loader too.
Chemix: this is the most irritating bug in PHP, fixed.
You can test these last updates via Composer with
"nette/nette": "~2.2.0@dev"
or download Nette-2.2dev.zip.
- chemix
- Nette Core | 1310
Thanks David,
without LiveTranslator is Tracy back :)
but if I want add LiveTranslator to Tracy I get this error
</html>
Fatal error: Class 'Nette\Latte\Macros\CoreMacros' not found in /.project./libs/LiveTranslator/Panel/Panel.php on line 174
and the “bad line is”
Nette\Latte\Macros\CoreMacros::install($latte->getCompiler());
- David Grudl
- Nette Core | 8218
chemix: are you using Composer? In this case the Nette Loader, responsible for creating class aliases, is not loaded. (Some aliases are created automatically, but not all of them, because it has negative performance impact.)
So there are two options: load NetteLoader manually in bootstrap.php:
Nette\Loaders\NetteLoader::getInstance()->register();
It will create aliases automatically on-the-fly, together with warnings. Or create all aliases manually, with no warnings:
array_walk(Nette\Loaders\NetteLoader::getInstance()->renamed, 'class_alias');
- chemix
- Nette Core | 1310
David: Yes, i use Composer.
use Nette\Application\Routers\Route;
use Nette\Diagnostics\Debugger;
use Nette\Configurator;
require __DIR__ . '/../vendor/autoload.php';
$configurator = new Configurator;
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->createRobotLoader()
->addDirectory(__DIR__)
->addDirectory(__DIR__.'/../libs')
->register();
NetteLoader is not RobotLoader?
- After I add
Nette\Loaders\NetteLoader::getInstance()->register();
i get Red screen with
User Warning
Class Nette\Latte\Macros\CoreMacros has been renamed to
Latte\Macros\CoreMacros
it's good, I know what I need to fix it. And after correct this line Tracy works with Live Translator
- but when i try add this line to code
array_walk(Nette\Loaders\NetteLoader::getInstance()->renamed, 'class_alias');
i get this
Warning: Cannot redeclare class Nette\Config\Configurator in /.project./app/bootstrap.php on line 13
Warning: Cannot redeclare class Nette\Config\CompilerExtension in /.project./app/bootstrap.php on line 13
Warning: Cannot redeclare class Nette\Diagnostics\BlueScreen in /.project./app/bootstrap.php on line 13
... and 9 others
- David Grudl
- Nette Core | 8218
Thats right. You can place @
before array_walk
or use:
array_walk(Nette\Loaders\NetteLoader::getInstance()->renamed, function($original, $alias) {
if (!class_exists($alias) && !interface_exists($alias)) {
class_alias($original, $alias);
}
});
(fixed after chemix comment)
- chemix
- Nette Core | 1310
This solution works perfect
@array_walk(Nette\Loaders\NetteLoader::getInstance()->renamed, 'class_alias');
the second solution (with if class exists) get this error
Warning: Cannot redeclare class Nette\Latte\IMacro in /.project./app/bootstrap.php on line 14
IMHO the best solution was with NetteLoader.
Thanks David.
- David Grudl
- Nette Core | 8218
Hmmm, there should be
if (!class_exists($alias) && !interface_exists($alias))
,
I fixed the code.
- David Grudl
- Nette Core | 8218
Hmmm, it's good point, Nette Loader is after ComposerLoader. https://github.com/…a4a046c39924
- chemix
- Nette Core | 1310
i try update nette from 2.1.2 to 2.2-rc4 on another project and get this red message :/
Nette\InvalidStateException
Found sections 'common', 'production', 'development' in configuration, but corresponding extensions are missing
common:
parameters:
site:
develMode: true
version: mavericks
php:
date.timezone: Europe/Prague
nette:
application:
errorPresenter: Error
session:
expiration: 14 days
services:
routerFactory: RouterFactory
router: @routerFactory::createRouter
factories:
production < common:
parameters:
site:
develMode: false
development < common:
...
// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon', $configurator::NONE); // none section
$container = $configurator->createContainer();
...
- ZZromanZZ
- Member | 87
Maybe this will help …
...
// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon', $configurator::AUTO);
$configurator->addConfig(__DIR__ . '/config/config.local.neon'); // none section
$container = $configurator->createContainer();
...
- David Grudl
- Nette Core | 8218
@chemix: this should show notice, fixed https://github.com/…b505257dde01
- chemix
- Nette Core | 1310
Just question,
now I get this error:
User Deprecated
Nette\DI\Container::__get() is deprecated; use getService() or enable nette.container.accessors in configuration.
after I added
nette:
application:
errorPresenter: Error
container: # <---
accessors: TRUE # <---
everything works, but I can't find “where is the problem?”
- MartinitCZ
- Member | 580
@**chemix**:
I think that:
$this->context->myCar // deprecated
$this->context->getService('myCar') // It is OK
- marian-r
- Member | 1
I can't update to the latest version, with the latest commit in bootstrap. I still have https://github.com/…585c38720564 as the latest.
composer.json:
"require": {
"nette/nette": "2.2.*",
},
"minimum-stability": "dev"
How to solve?
- MartinitCZ
- Member | 580
@**chemix**: This would be better:
$container->getByType('\Nette\Application\Application')->run();
- Eda
- Backer | 220
I also migrate some of my projects to Nette 2.2 RC4. It works fine a I didn't notice any big problem.
The only things it was necessary to change:
1.
// from
$latte->registerHelper(...)
// to
$latte->addFilter(...)
2.
Thats a pitty, that there is no full replacement for helper loaders. Now, if you
have class with lot of functions and each of them is helper, you have to iterate
over them and add each helper separately.
// from
$latte->registerHelperLoader()
// to
foreach (...) {
$latte->addFilter(...)
}
3.
Fix “Declaration of MyMacros::install() should be compatible with
Latte\Macros\MacroSet::install(Latte\Compiler $compiler)”
class MyMacros extends MacroSet
{
//public static function install(\Nette\Latte\Compiler $compiler)
public static function install(\Latte\Compiler $compiler)
{
...
}
}
Question related to composer: is there any way to allow
minimum stability beta
only for nette and its packages? Now, if
I have something like this in composer.json
:
{
...
"require": {
"php": ">=5.3.2",
"nette/nette": "~2.2.0",
"kdyby/translation": "@dev",
...
},
"minimum-stability": "beta"
}
It installs for instance instead of Symfony/Translation 2.4 (stable) beta version of 2.5. It is not problem for now, but it could be in future and in more complex projects.
So… thank you, well done.
Last edited by Eda (2014-05-11 11:26)
- Jan Tvrdík
- Nette guru | 2595
@Majkl578: That will not work. He needs to list all
nette packages with @beta
.
- MartinitCZ
- Member | 580
@**David Grudl**: Please, can you create lisf of changes, between 2.1 & 2.2 (renamed classes..)?