Quickstart and exact requirements

Notice: This thread is very old.
madic
Member | 10
+
0
-

Hi,

i just came across your charming framework would like to jump in for a small project.

Some questions:

PHP 5.3 required – that´s a crystal clear statement, however, i find download files like “Nette2.0.10-PHP5.2”

Q1) I guess i will have to keep PHP 5.25 on our server for some more time – will those 5.2 files run fine or should i forget about it for now? My project aims at internal production use.

Q2) What´s that ‘nonprefix’ download version about?

Q3) Is the Quickstart tutorial suited for PHP 5.2? I am stuck for a second time regarding namespace issues…
Installed: NetteFramework-2.0.10-PHP5.2.zip
Webspace environment: PHP 5.25
My latest action as of the tutorial
Have added:

...
public function __construct(Nette\Database\Connection $database)
...

Get error:

Parse Error
syntax error, unexpected T_STRING, expecting '&' or T_VARIABLE
File: ...\app\presenters\HomepagePresenter.php   Line: 11
11:        public function __construct(NetteDatabaseConnection $database)

Ah yeah, Tracy drops the backslash chars. But they´re stored, thats´s not the reason for this…

I´d be happy if you had a solution – i need a cool framework and really like what i´ve read so far. Thanks!

CherryBoss
Member | 608
+
0
-

Hello,
in forward I excuse for my bad English.

A1) If you have PHP 5.3 installed on your server, there is no reason to use Nette for PHP 5.2. Functionality of those two versions is exactly same. Diference is only in namespaces and classnames (PHP 5.2 does not support namespaces).

A2) For PHP 5.2 there is prefixed and non-prefixed version. It is recommended to use prefixed version to avoid conflicts in common classnames if you are using another PHP libraries. For find diferences you can visit http://nette.merxes.cz/api/. In most cases there is only “N” prefix is classname (NObject, NConnection etc.)

A3) Quickstart tutorial is suited for PHP 5.3 (Nette 2.0.10 for PHP 5.3). In order to follow this tutorial when using PHP 5.2 you have to change classnames.

Your error can be fixed with changing:

...
public function __construct(Nette\Database\Connection $database)
...

to:

...
public function __construct(NConnection $database) // In prefixed version
public function __construct(Connection $database) // In non-prefixed version
...
madic
Member | 10
+
0
-

Hey thanks!

N prefix for 5.2 – got that!

Changed that type and ran into the next Tracy notice. Ok, doesn´t seem to be fatal. Will disable Tracy to try to get along the tutorial.

Tracie´s rant, just for the curious:

Notice
Undefined property: NRow::$Field
Stack:
...\libs\Nette\Database\Statement.php:104 source ►  NRow-> offsetGet (arguments ►)
...\libs\Nette\Database\Row.php:26 source ►  NStatement-> normalizeRow (arguments ►)
...\libs\Nette\Database\Drivers\MySqlDriver.php:159 source ►  NRow-> __construct (arguments ►)
...\libs\Nette\Database\Reflection\DiscoveredReflection.php:78 source ►  NMySqlDriver-> getColumns (arguments ►)
...\libs\Nette\Database\Table\Selection.php:93 source ►  NDiscoveredReflection-> getPrimary (arguments ►)
...\libs\Nette\Database\Connection.php:238 source ►  NTableSelection-> __construct (arguments ►)
...\app\presenters\HomepagePresenter.php:18 source ▼  NConnection-> table (arguments ►)
18:                    $this->template->posts = $this->database->table('posts')
19:                            ->order('created_at DESC')
20:                            ->limit(5);

Still based on file NetteFramework-2.0.10-PHP5.2.zip

Cheers!

Jan Tvrdík
Nette guru | 2595
+
0
-

PHP 5.3 required – that´s a crystal clear statement, however, i find download files like “Nette2.0.10-PHP5.2”

PHP 5.2 is still fully supported in stable (2.0.x) and the support in 2.1-dev (master branch in repository) was dropped very recently.

CherryBoss
Member | 608
+
0
-

Please could you save Tracy file as normal HTML file when an error appear and upload it somewhere? Than we will be able to click throught the Tracy and see, whats wrong. Thanks

On what step it fails now for you?

Last edited by CherryBoss (2013-05-29 14:42)

madic
Member | 10
+
0
-

Yeah thanks, once having ‘passed’ the tutorial i´ll collect those eager Tracy alerts.

Right now, i´m stuck at the form callback.

Taken from Saving to Database:

$form->onSuccess[] = $this->commentFormSucceeded; // without parenthesis

That´s about those closure thingies, right? Guess that´s not supposed to work with 5.2, but how has it been done back then?

Filip Procházka
Moderator | 4668
+
0
-

The old way (that's support will probably never be dropped) is simple

$form->onSuccess[] = callback($this, 'commentFormSucceeded'); // without parenthesis

Last edited by Filip Procházka (2013-05-30 12:40)

madic
Member | 10
+
0
-

hmmm still no success…

There are no errors, but still the commentFormSucceeded callback isn´t called back, hence no record gets stored. Tried to understand how class NForm deals with the onSuccess array, but for me, that´s too deep inside. Any more ideas?

Hey thanks for your support!

CherryBoss
Member | 608
+
0
-

Here is something about events: https://doc.nette.org/…/smartobject#…
Here is something about callbacks: https://doc.nette.org/…/smartobject#…

Are you sure that callback is not fired? Try this:

public function commentFormSucceeded($form)
{
    dump("Callback fired!");
}

Than submit form and if there will be dumped text in the page it means callback has been fired and problem is somewhere else.

Edit: matej21 below is right! :-)

Last edited by CherryBoss (2013-05-30 14:22)

David Matějka
Moderator | 6445
+
0
-

You have to use Nette\Application\UI\Form (NAppForm in prefixed version) in MVP application (in presenters and components)

madic
Member | 10
+
0
-

Yeah, he IS right – that´s been it.
So i went on following the quickstart.

I1) Have an issue with sending the login form.

NMissingServiceException: Multiple services of type IAuthenticator found.
in ...libs\Nette\DI\Container.php:218

I2) But – meanwhile, really annoying – enabling tracy brings up a notice on every page, so it´s not that useful. Maybe we can address this one first?

Notice: Undefined property: NRow::$id
in ...\libs\Nette\Database\Row.php:42

The good news: according to your advice i´ll provide those error html files. I´m just a bit picky where to post the download links… PM, anyone??? :)

Last edited by madic (2013-06-03 21:42)

Jan Tvrdík
Nette guru | 2595
+
0
-
NMissingServiceException: Multiple services of type IAuthenticator found.
in ...libs\Nette\DI\Container.php:218

Try not to have multiple definitions :) If you find the SystemContainer class (which should be located inside temp/cache/_Nette.Configurator directory) it should have a property $classes and inside is an information which two (or more) services are of type IAuthenticator. Or just copy your config.neon here, it's usually easy to figure it out.

I´m just a bit picky where to post the download links

If you haven't send them to anyone already you can send them to me and I will have a look at them.

madic
Member | 10
+
0
-

Thanks, have sent you a message.

Here´s an excerpt from my latest cached configurator file:

	public $classes = array(
		// ... some stuff, then only ONE iauthenticator line:
		'iauthenticator' => FALSE, //: nette.authenticator, authenticator,

Sooo… wrong error message, having NO iauthenticator?

Is that line from quickstart tutorial still true?

Add a security section to your config.neon (and don't forget to change the password):

nette:
    security:
        users:
            admin: secret  # user 'admin', password 'secret'

Nette will automatically create a service authenticator into DI Container.

Allright, here´s my config.neon

common:
	parameters:
	php:
		date.timezone: Europe/Prague
		# zlib.output_compression: yes
	nette:
		application:
			errorPresenter: Error
		database:
			dsn: 'mysql:host=localhost;dbname=sandbox'
			user: guessUrself
			password: 'really'
		session:
			expiration: 4 days
		security:
			users:
				sandbox: 'mrSB,,sandbo'
	services:
		authenticator: Authenticator
		routerFactory: RouterFactory
		router: @routerFactory::createRouter
	factories:
production < common:
development < common:
madic
Member | 10
+
0
-

Ha!

UPDATE: Login now works.

Changed my config.neon

	services:
#		authenticator: Authenticator
		routerFactory: RouterFactory
		router: @routerFactory::createRouter

Guess this turns off some ‘dummy authenticator’ to be replaced by a real one knowing my users? Have i missed something in the tutorial?

Jan Tvrdík
Nette guru | 2595
+
0
-

The reasons for the “Multiple services of type IAuthenticator found” error is that having the following in config.neon actually defines service nette.authenticator as instance of NSimpleAuthenticator

security:
    users:
        sandbox: 'mrSB,,sandbo'

and having the following in config.neon defines service named authenticator as instance of Authenticator.

services:
    authenticator: Authenticator

When signing in, a service implementing IAuthenticator interface is required. Having defined two services which implement the interface leads obviously to error, because Nette can not determine which one to use.


Now I'll go check my email.

madic
Member | 10
+
0
-

Hi Jenny,

i guess you followed the quickstart guide and took the ‘sandbox’ folder to start your project? Make the contained ‘www’ folder your webroot.

Hope that helps?

madic
Member | 10
+
0
-

Oh yeah, sorry…

Given a ‘mybox’ presenter (which equals controller) it would be at least
yoursite.org/mybox

or according to location of your www folder, respectively
yoursite.org/nette/sandbox/www/mybox

should also work out fine

Last edited by madic (2013-08-28 09:15)

madic
Member | 10
+
0
-

jenny wrote:


So do I need to create the model, presenter & templates folder there?

Hm, been a while since i´ve hacked my tool with nette…

Really, just follow the quickstart and don´t miss to write down some notes! They´ve done an awesome job and it will outline all that stuff.

But yes, all files you edit or create are located within the sandbox. I just took the whole sandbox contents to start my project.