Building First Application

Notice: This thread is very old.
Lawi
Member | 1
+
0
-

Hi, Kindly may someone tell me how i can create a simple application using Nette, am new to it and trying to learn as first as i can. Does it have code generation like Yii..?

hrach
Member | 1838
+
0
-
madalina
Member | 7
+
0
-

Hello,
Could anyone explain me, please, how the jobs work in Nette Framework?
Or more exactly how could I run a job at certain hours or in certain days.
Is there any English documentation about that?
Thank you!
Regards,
Madalina

Milo
Nette Core | 1283
+
0
-

Hi,

Nette Framework does not contain such tools. It is a bundle of PHP libraries for fast and safe web pages/applications/services development.

For scheduled runs you must use other tools, like cron on Linux or Task Scheduler on Windows.

Or maybe I misunderstood your question.

Last edited by Milo (2013-01-30 13:20)

madalina
Member | 7
+
0
-

thank you for your answer!
so I should simply create a php file and run it from cron?
or could you recommend some tutorial about this process?

Milo
Nette Core | 1283
+
0
-

You're welcome.

It depends on your situation. Do you have Nette application already written and are you looking for scheduled task running within the application? Or… are you writing new scheduled task in PHP?

Don't be shy and post more information with details…

madalina
Member | 7
+
0
-

Well.. I have the application already written. And now I want to create a new php script related to this application, which should run automatically at some date. The script fills in some information in the database for certain users and sends confirmation emails.
So after I have this new script I don't really know which are the next steps.

hrach
Member | 1838
+
0
-

I suggest creating some bootstrap file without routing, then two different bootstrap files, which includes the first one, and each of them add routing. The first one adds classic web routing, the second one adds CliRouter.

Then just add to you cron sth like:

php /path/to/boostrap_with_cli_router.php YourPresenter:action -param=test
Honza Kuchař
Member | 1662
+
0
-

CliRouter looks very interesting and useful!

Last edited by Honza Kuchař (2013-02-06 14:10)

ezraobiwale
Member | 2
+
0
-

Hi. I'm totally new to the NF. I've got the quickstart but it won't work. I get a 500 Server Error. What to do?

Jan Tvrdík
Nette guru | 2595
+
0
-

@ezraobiwale: There are two types of server errors.

  1. Apache Server Error (screen) is usually caused by something in www/.htaccess. Use Apache log to determine more details.
  2. Nette Server Error (screen) usually happen if temp or log is not writable. Use Nette log (in log directory) to determine more details.
DavidTheNewbie
Member | 79
+
0
-

Hello to you all. I am a complete beginner currently wondering digging into templating. I am at a loss as to why {block name}{/block} is properly translated by the engine and {define name}{/define} or {capture name}{/capture} throws an error saying that it is an uknown macro. Thanks beforehand for a kickstart.

Last edited by DavidTheNewbie (2014-01-19 12:36)

Jan Tvrdík
Nette guru | 2595
+
0
-

This should obviously work so I have two questions for you

  1. What version of Nette do you use?
  2. Can you post here an example of the template which throws the “unknown macro” error?
DavidTheNewbie
Member | 79
+
0
-

Hi,

Nette 2.1.0, PHP > 5.3.

@layout-test.phtml contains the following code
<div style=‘background-color:Red;’>
<p>Jméno {block #name}{/block}</p>
<p>Příjmení {block #surname}{/block}</p>
</div>

default.phtml contains the following code
{include '@layout-test.phtml'}
{block #name}David{/block} … ok
{block #surname}Frog{/block} … ok, i.e. displays data twice – both in the included layout and from the block

but when BLOCK is renamed to DEFINE

{define #name}David{/define} … throws unknown macro error
{define #surname}Frog{/define} … throws unknown macro error

When I switch the .PHTML extension of the DEFAULT.PHTML to .LATTE to see for example if the DEFAULT.LATTE translates it correctly, the Debugger says that it cannot locate the DEFAULT.PHTML file.

Last edited by DavidTheNewbie (2014-01-19 15:22)

Filip Procházka
Moderator | 4668
+
0
-

First of all .phtml is deprecated, you should use .latte. But I have no idea why the macros don't work, would you mind pasting a link for expanded Tracy screenshot?

Also, the forum has formating tags for code, you should learn how to use it, since you're probably gonna be visiting us often as a beginner :)

And next time create please a separate topic, thanks.

Last edited by Filip Procházka (2014-01-19 15:28)

DavidTheNewbie
Member | 79
+
0
-

Hi

Ok, .PHTML is deprecated, but renaming it to .LATTE throws an error saying that a … .PHTML file is missing which should not be so if I´m using the latest version of Nette. Here are the screenshots of the Tracy error messages when trying to use {define}{/define} instead of {block}{/block}: obr1 obr2 Thanks guys for your time and energy.

Last edited by DavidTheNewbie (2014-01-19 17:05)

Jan Tvrdík
Nette guru | 2595
+
0
-

You don't have Nette 2.1, according to the screenshots you have installed Nette 0.8.0 released on 2009–05–04. Where did you get this version anyway?

DavidTheNewbie
Member | 79
+
0
-

This is becoming really suspicious as I clicked to download the latest version and, as a result, the NetteFramework-2.1.0 folder was obtained and is now being used for testing by me. How is that possible? Is the download link misleading?

Last edited by DavidTheNewbie (2014-01-19 17:39)

Jan Tvrdík
Nette guru | 2595
+
0
-

I strongly believe that is not possible to find a link for downloading Nette 2.1.0 which would actually download 0.8.0. In every release archive there is a file version.txt which clearly states which version you have downloaded.

DavidTheNewbie
Member | 79
+
0
-

You were absolutely right. Just accidentally mixed two versions. Now, the latest version is already in place, but another error is thrown as is visible here.

My index.php:

<?php
// absolute filesystem path to the web root
define('WWW_DIR', dirname(__FILE__));

// absolute filesystem path to the application root
define('APP_DIR', WWW_DIR . '/../app');

// absolute filesystem path to the libraries
define('LIBS_DIR', WWW_DIR . '/../libs');

// load bootstrap file
require APP_DIR . '/bootstrap.php';

My bootstrap.php:

<?php
// pokud používáte verzi pro PHP 5.3, odkomentujte následující řádek:
use Nette\Application\Routers\Route,
	Nette\Application\Routers\SimpleRouter;


// Step 1: Load Nette Framework
require LIBS_DIR . '/Nette/loader.php';

// Configure application
$configurator = new Nette\Configurator;

// Enable Nette Debugger for error visualisation & logging
$configurator->setDebugMode(TRUE);
$configurator->enableDebugger(__DIR__ . '/log');

// Enable RobotLoader - this will load all classes automatically
$configurator->setTempDirectory(__DIR__ . '/temp');
$configurator->createRobotLoader()
	->addDirectory(APP_DIR)
	->addDirectory(LIBS_DIR)
	->register();

// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config.neon');
$container = $configurator->createContainer();

// Setup router using mod_rewrite detection
if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules())) {
	$router = $container->getService('router');
	$router[] = new Route('index.php', 'Machine:show', Route::ONE_WAY);
	$router[] = new Route('<presenter>/<action>[/<id>]', 'Machine:show');

} else {
	$container->addService('router', new SimpleRouter('Machine:show'));
}

return $container;

My config.neon file:

#
# SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
# https://nette.org/en/security-warning
#
php:
	date.timezone: Europe/Prague

nette:
	database:
		dsn: "sqlite:%appDir%/model/demo.db3"

services:
	- Authenticator
	- AlbumRepository

This whole framework appears to be an amazing one but I´m having difficulties starting it all up.

Last edited by DavidTheNewbie (2014-01-21 14:08)

screenas
Member | 5
+
0
-

this neither seems to be Nette 2.1.0
have you already tried the new Quickstart?

With composer it worked for me like a charm.

DavidTheNewbie
Member | 79
+
0
-

Hi, it really is the right version as the info at the bottom of the page reveals. I´ll give the Quickstart a try and we will see.

Last edited by DavidTheNewbie (2014-01-21 14:09)

Jan Tvrdík
Nette guru | 2595
+
0
-

@DavidTheNewbie: Can you send me the copy of your config.neon which causes the trouble? But I need the exact binary copy not just the copy of the file content. Upload it e.g. to ulozto.net and post here a link.

DavidTheNewbie
Member | 79
+
0
-

So here I am again. I just wanted to see the QuickStart project running, so having downloaded it from GitHub and trying to run it, an error is thrown as already mentioned above. Here are the neon and neon local files but without any modifications from my side.

Last edited by DavidTheNewbie (2014-01-21 14:11)

Šaman
Member | 2659
+
0
-

Show your bootstrap.php, pls. I think you dont enable sections for neon and in 2.1 its disabled by default (common, production, development).

DavidTheNewbie
Member | 79
+
0
-

Hi

Here is my bootstrap.php The neon sections seem enabled to me:

<?php

// Load Nette Framework or autoloader generated by Composer
require __DIR__ . '/../libs/Nette/loader.php';


$configurator = new Nette\Config\Configurator;

// Enable Nette Debugger for error visualisation & logging
$configurator->setDebugMode(TRUE);
$configurator->enableDebugger(__DIR__ . '/../log');

// Specify folder for cache
$configurator->setTempDirectory(__DIR__ . '/../temp');

// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()
	->addDirectory(__DIR__)
	->addDirectory(__DIR__ . '/../libs')
	->register();

// 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();

return $container;

And here is the error thrown.

Last edited by DavidTheNewbie (2014-01-21 13:24)