Nette Framework 2.3.0 released!

Notice: This thread is very old.
David Grudl
Nette Core | 8229
+
+34
-

One – two – three, we are very proud to announce the Nette Framework two three!

Application

  • all presenters are created by Dependency Injection container
  • added LinkGenerator
  • Presenter: changed handling of invalid link, they triggers warnings on production and are configurable on development via ‘silentLinks’
  • Routing: speed optimization & caching
  • added bridges for Nette DI
  • added Request::getParameter(), deprecated Request::isPost()

BC breaks:

  • routes and presenter names are case sensitive. Nette will warn you if you use the wrong case in presenter name. But due to performance limitation it is not checking Route mask – you should check them manually. Correct is <presenter=UpperCasedDefaultValue> and <presenter url-cased-regexp-mask>.
  • Route::addStyle() & Route::setStyleProperty() are deprecated and now will trigger E_USER_DEPRECATED
  • removed support for deprecated Nette\Templating, template extension .phtml and old link syntax (undeprecated in 2.3.2)

Bootstrap

  • in config file you can move all sections placed in nette to one level up. If you move up one of the sections container, mailer or debugger, rename it to di, mail and tracy.
  • added Configurator::addServices()
  • uses new DI\ContainerLoader
  • removed deprecated constants Configurator::DEVELOPMENT & PRODUCTION (BC break)
  • Configurator::setDebugMode() accepts only bool / string / array

Caching

  • FileStorage: removed usage of realpath()
  • added bridge for Nette DI
  • ancient and deprecated ArrayAccess syntax $val = $cache[$key] or $cache[$key] = $val triggers E_USER_DEPRECATED. Use please $cache->load($key) and $cache->save($key, $val)

Database

  • throws own exceptions:
    • DriverException, ConnectionException
    • ConstraintViolationException, ForeignKeyConstraintViolationException, NotNullConstraintViolationException and UniqueConstraintViolationException
  • added support for += and -= in UPDATE statement
  • added support for operators in WHERE & AND
  • implemented ?and ?or ?set ?values ?order ?name
  • added support for ‘.’ in column names
  • forbidden syntax ‘sql’, ‘sql’, …, i.e. after every SQL string must be at least one parameter
  • SqlLiteral is parsed using SqlPreprocessor
  • table and column names in joins can begin with number or underscore
  • classes *Reflection split into with *Conventions & Structure
  • added IRowContainer::fetchAssoc(), ISupplementalDriver::convertException() (BC break)
  • PgSqlDriver: fixed formatLike() #46
  • MySqlDriver by default uses utf8mb4 encoding for MySQL >= 5.5.3 instead of utf8 (possible problem)
  • Connection: undeprecated some methods
  • DatabaseExtension: added alias ‘database.x.connection’ for ‘database.x’
  • to ensure that new SQL translator do the same job as older one, you can install special tool named CompatibilityChecker22

Deprecated

new package for deprecated stuff

DI

  • parameters auto-resolution for generated factories
  • service aliases
  • removed ServiceDefinition & Statement magic methods (makes it 3× faster)
  • added DecoratorExtension, DIExtension and InjectExtension
  • added CompilerExtension::validateConfig()
  • ExtensionsExtension: allows to pass params
  • dynamic services
  • chained syntax Class::method()::method()::method()
  • removed dependency on nette/reflection
  • ContainerFactory replaced with light ContainerLoader
  • ContainerBuilder: implement escaping of ‘@’ at the beginning of string
  • Compiler: added addConfig() & loadConfig(), compile() returns ClassType[]

BC breaks:

  • Container & ContainerBuilder::findByType() returns all services, including non-autowired
  • class names are case sensitive
  • removed support for placing services inside extension section in configuration file
  • removed support for dynamically added extensions

Finder

  • Finder::filter() callback always receives as argument (at least) a FilesystemIterator
  • Finder is countable

Forms

  • fixed some limitations of netteForms.js
  • TextBase: input is not silently truncated to max-length
  • TextBase::addFilter() is processed during validation, added Rules::addFilter()
  • now you can add filters to conditions $input->addCondition(...)->addFilter(...)
  • to Container::onValidate callbacks are passed values via second parameter
  • added bridge for Nette DI
  • internal filtering methods like Nette\Forms\Controls\TextBase::filterFloat was removed
  • internal validation methods like Nette\Forms\Controls\TextBase::validateFloat was moved to Nette\Forms\Validator, as well as Rules::$defaultMessages
  • Buttons and Hidden fields are generated without HTML ID. Relying on autogenerated ID is very bad, if you want ID, set it via setHtmlId()
  • RadioList items are generated without ID too. You can enable it via $radioList->generateId = TRUE. But again: set you base ID via setHtmlId()
  • DefaultFormRenderer adds classes to inputs & label only during rendering process (BC break)

Http

  • RequestFactory: speed optimizations
  • Url: internally stores query parameters as array, improved canonicalize(), etc…
  • added briges for Nette DI
  • added Helpers::formatDate(), added IResponse::getHeader() (BC break)
  • Request::getUrl() is immutable
  • Response::date(), Request::isPost() & Request::getFile() with multiple keys are deprecated

Latte

  • template is wrapped in an class → much faster repeated rendering
  • faster loading from cache file
  • faster autoloader for non-Composer usage
  • {ifset block} & {elseifset block} without #
  • parser detects for unclosed / malformed macros (nette/nette#711)
  • added support for <script type="text/html"> (#24 & nette/nette#705)
  • added macro {php …} as replacement for {? …}
  • fills Html::$attrs with actual attribute values
  • “words” can contain concatenation dots (i.e. {include $dir . '/template.latte'} #26)
  • combination of n:class & class leads to exception

Mail

  • added bridge for Nette DI
  • variable $mail is not automatically passed to templates, you have to do it yourself (BC break) (but better than {var $mail->subject = "Your new order"} is this <title>Your new order</title>, isn't it?)
  • if you have linked images (with relative paths) in template, pass base file path to images as second parameter to setHtmlBody()
  • Message: removes <title> from body

Neon

  • chained syntax first(a, b)second(1, 2)

Php Generator

  • generating PHP files with multiple namespaces & classes
  • removed magic methods (makes it much faster)
  • splits long lines, uses single-quotes strings when possible
  • short phpDoc for properties

Reflection

  • added Helpers::getDeclaringClass()
  • added bridge for Nette DI

Robot Loader

  • added support for loading from Phar
  • removed usage of realpath()
  • is now case sensitive and will warn you if you use the wrong case in class name

Safe Stream

  • it is recommended to change protocol safe://... to namespaced nette.safe://...
  • protocol is registered automatically, no longer need to call SafeStream::register()

Security

  • added bridge for Nette DI

Tracy

  • Bluescreen & Debug Bar: 10× smaller HTML code, 10× faster, deeper depth of dumps
  • Debug Bar: redesigned, uses vector icons
  • Bluescreen: dumps contain location of class definition (can be opened in editor with ctrl key)
  • Bluescreen: added link “skip error” to suppress strictMode
  • Bluescreen: added Exception panel
  • added Tracy\ILogger and rewritten default Logger
  • Debugger::enable() implements checking of cookie (format cookie@ip.address)
  • customizable 500 error template via Debugger::$errorTemplate
  • Dumper: new options LOCATION_SOURCE, LOCATION_LINK, LOCATION_CLASS
  • Dumper: customizable object exportes
  • completely rewritten JavaScript, now requires IE 10+ (removed tracyQ.js)
  • added bridge for Nette DI

Utils

  • added Arrays::normalize(), Callback::invokeSafe(), Html::data()Strings::firstLower()
  • Image::from() throws ImageException when is unable to decode file
  • Image::place() fixes support for alpha channel
  • Callback::closure() returns native closures since PHP 5.4
  • Strings::chr() throws Nette\InvalidArgumentException if code point is not in valid range
  • Validators::isUrl() accepts underscores in subdomains
Zdenal
Member | 21
+
0
-

Hi,

I have problem with tracy. After i upgraded version 2.2.7 to 2.3 debug panel disappear. When I look to source code, panel's code is at the end of code after the tag html, but on the screen it is not showing. There is an error in console TypeError: JSON.parse is not a function.

Can you help me? Thank you.

bckp
Member | 12
+
0
-

@Zdenal What browser you use? Have you tried other browser?

Zdenal
Member | 21
+
+1
-

bckp wrote:

@Zdenal What browser you use? Have you tried other browser?

FF 35.0.1

Console in Chrome

Uncaught TypeError: undefined is not a functionVM98:15 c.restorePositionVM98:14 c.initVM98:15 g.init(index):491 (anonymous function)

Tomáš Pilař
Member | 14
+
0
-

Zdenal wrote:

bckp wrote:

@Zdenal What browser you use? Have you tried other browser?

FF 35.0.1

Console in Chrome

Uncaught TypeError: undefined is not a functionVM98:15 c.restorePositionVM98:14 c.initVM98:15 g.init(index):491 (anonymous function)

Same here.

H0w4rd
Member | 96
+
0
-

My project doesn't work with 2.3.0 because of an error:

[Mon Mar 02 13:59:05.884320 2015] [core:notice] [pid 3691] AH00052: child pid 15391 exit signal Segmentation fault (11)

after submitting a form, the method for saving the form is not called, browser says ‘Connection interrupted’, nothing in log directory, no tracy shown.
PHP 5.5.15 and 5.6.5

David Grudl
Nette Core | 8229
+
0
-

JSON.parse should work nearly everywhere.

David Grudl
Nette Core | 8229
+
0
-

@zdenal @nethry was it fixed by Firefox 36, or problem persists?

Pavel Janda
Member | 977
+
0
-

Nette 2.3 moved displayed error call stack one level above. Why is that?

For example: this Tracy output will tell me absolutely nothing about what happened.

2.2 is more friendly with “Can not write to temp dir”, or something particular like that..

PS: Sorry about the attached image, try zooming out.

Last edited by Beton (2015-03-10 15:36)

David Grudl
Nette Core | 8229
+
0
-

I don't know what you mean by moving one level above, but this error is fixed in master.

vvoody
Member | 910
+
0
-

My experience of updating nette from 2.2 to 2.3 on my project:

  • ITemplateFactory::createTemplate was changed, so I needed to change my custom TemplateFactory also

http://prntscr.com/6f5ysb
https://api.nette.org/…ory.php.html#22
https://api.nette.org/…ory.php.html#22

  • Autowiring of class FileStorage no longer works, now is defined in CacheExtension as interface IStorage
Pavel Janda
Member | 977
+
0
-

David Grudl wrote:

I don't know what you mean by moving one level above, but this error is fixed in master.

That means old Nette would tell me this:

1, Something wrong in Application
2, Something wrong in PresenterFactory
3, An unreadable underhood error
4, **Can not write to temp dir**

While new Nette throws:

1, Something wrong in Application
2, Something wrong in PresenterFactory
3, **An unreadable underhood error**

Last edited by Beton (2015-03-11 12:05)

David Grudl
Nette Core | 8229
+
0
-

I don't understand. Btw on your screenshot is E_WARNING (and not related to temp dir), not exception.

Zdenal
Member | 21
+
0
-

David Grudl wrote:

@zdenal @nethry was it fixed by Firefox 36, or problem persists?

@michal.lohnisky I don't know what exactly you mean by “ID handling”. Can you open new thread for it?

problem persists. Same problem in chrome and IE.

David Grudl
Nette Core | 8229
+
0
-

It seems like problem with firewall or whatever out of Nette.

Zdenal
Member | 21
+
0
-

David Grudl wrote:

It seems like problem with firewall or whatever out of Nette.

Maybe yes. And I use foundation framework and bootstrap framework but I hope there is no problem with.

And I use translator in this panel.

Last edited by Zdenal (2015-03-11 14:13)

Pavel Janda
Member | 977
+
-1
-

David Grudl wrote:

I don't understand. Btw on your screenshot is E_WARNING (and not related to temp dir), not exception.

All right, i have been mistaken, it is not thrown by Nette at all.

But still, people won't understand that "touch(): Utime failed: Permission denied" means they have to change permission bits on “temp” directory..

Edit: And yes, it is related to “temp” dir.

Last edited by Beton (2015-03-11 18:53)

David Grudl
Nette Core | 8229
+
+1
-

It is solved in master and is not related to temp dir. Look at $touchToRefresh.

Pavel Janda
Member | 977
+
0
-

The warning no longer pops up when i put ownership of temp dir to hands of _www user, or chmod the temp dir.

Ok.

David Grudl
Nette Core | 8229
+
0
-

@zdenal @nethry fixed

Matúš Matula
Member | 257
+
0
-

protocol is registered automatically, no longer need to call SafeStream::register()

does not work automatically for me.. I still need to register manually otherwise I get Unable to find the wrapper "nette.safe"

chemix
Nette Core | 1310
+
0
-

New Tracy has JavaScript colision with MooTools framework :-/ any idea how to debug it? How run Tracy without minification?

David Grudl
Nette Core | 8229
+
0
-

Did you install nette using composer?

radas
Member | 225
+
0
-

I have the same problem as @MatúšMatula. No file inside temp/cache does not contain something like “Nette\Utils\SafeStream::register()”. When I added “Nette\Utils\SafeStream::register();” to the bootstrap.php, then it works.

greeny
Member | 405
+
0
-

@radas @MatúšMatula if you install Nette/SafeStream using composer, the protocol is registered automatically.

See loader.php and composer.json . There is no longer registration through SystemContainer.

radas
Member | 225
+
0
-

Class Nette\Utils\SafeStream is marked as internal. Is correct to register it manually via Nette\Utils\SafeStream::register() in bootstrap.php or exists any way how to do this in config.neon?

chemix
Nette Core | 1310
+
0
-

@DavidGrudl I add this line to sandbox (and remove jquery cdn) and I get this JavaScript error

<script src="//cdnjs.cloudflare.com/ajax/libs/mootools/1.5.1/mootools-core-full-compat.js"></script>

problem with MooTools is, that they extend basics JS objects :(

David Grudl
Nette Core | 8229
+
+1
-

@chemix can you check it with Tracy 2.3.1?

chemix
Nette Core | 1310
+
+2
-

@DavidGrudl It works! You are my hero :) thanks!

Pavel Janda
Member | 977
+
0
-

@DavidGrudl Nette\DI\Extensions\InjectExtension throws unrecognized Exception viz: http://www.tiikoni.com/tis/view/?…
(nette/di v2.3.1)

Fatal Error

Class 'Nette\DI\Extensions\ServiceCreationException' not found

in nette/di/src/DI/Extensions/InjectExtension.php:128

Last edited by Beton (2015-03-27 20:13)

radas
Member | 225
+
0
-

As @DavidGrudl wrote: “Route::addStyle() & Route::setStyleProperty() are deprecated and now will trigger E_USER_DEPRECATED”.

What is the substitute for these methods?

Many thanks.

Aurielle
Member | 1281
+
0
-

Define filters on each parameter, like this:

$router[] = new Route('...', [
	'presenter' => [
		Route::VALUE => 'Homepage',
		Route::FILTER_IN => function(...) { ... },
		Route::FILTER_OUT => function(...) { ... },
	],
	...
]);
David Grudl
Nette Core | 8229
+
0
-

@Beton fixed

kubco2
Member | 9
+
0
-

David Grudl wrote:

@Beton fixed

I installed nette 2.3.1 from composer and there it is still not fixed.

David Grudl
Nette Core | 8229
+
0
-

It will be fixed in 2.3.2.