Building First Application

1. about a year ago

Lawi
Member
Registered: 2013-01-21
Posts: 1

Building First Application

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..?

 

2. about a year ago

hrach
Moderator
Registered: 2007-03-11
Location: Brno
Posts: 1303

Re: Building First Application

 

3. about a year ago

madalina
Member
Registered: 2013-01-30
Posts: 7

Re: Building First Application

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

 

4. about a year ago

Milo
Moderator
Registered: 2010-05-04
Posts: 736

Re: Building First Application

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)

 

5. about a year ago

madalina
Member
Registered: 2013-01-30
Posts: 7

Re: Building First Application

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?

 

6. about a year ago

Milo
Moderator
Registered: 2010-05-04
Posts: 736

Re: Building First Application

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…

 

7. about a year ago

madalina
Member
Registered: 2013-01-30
Posts: 7

Re: Building First Application

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.

 

8. about a year ago

hrach
Moderator
Registered: 2007-03-11
Location: Brno
Posts: 1303

Re: Building First Application

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

 

9. about a year ago

Honza Kuchař
Moderator
Registered: 2007-08-12
Location: Brno
Posts: 1551

Re: Building First Application

CliRouter looks very interesting and useful!

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

 

10. about a year ago

ezraobiwale
Member
Registered: 2013-03-25
Posts: 2

Re: Building First Application

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?

 

11. about a year ago

Jan Tvrdík
Nette guru
Registered: 2008-04-13
Location: Prostějov
Posts: 1883

Re: Building First Application

@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.

 

12. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

13. 3 months ago

Jan Tvrdík
Nette guru
Registered: 2008-04-13
Location: Prostějov
Posts: 1883

Re: Building First Application

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?

 

14. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

15. 3 months ago

Filip Procházka
Moderator
Registered: 2009-06-01
Location: Brno
Posts: 4035

Re: Building First Application

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)

 

16. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

17. 3 months ago

Jan Tvrdík
Nette guru
Registered: 2008-04-13
Location: Prostějov
Posts: 1883

Re: Building First Application

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?


 

18. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

19. 3 months ago

Jan Tvrdík
Nette guru
Registered: 2008-04-13
Location: Prostějov
Posts: 1883

Re: Building First Application

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.


 

20. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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!
# http://nette.org/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)

 

21. 3 months ago

screenas
Member
Registered: 2014-01-05
Posts: 7

Re: Building First Application

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.

 

22. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

23. 3 months ago

Jan Tvrdík
Nette guru
Registered: 2008-04-13
Location: Prostějov
Posts: 1883

Re: Building First Application

@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.


 

24. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

25. 3 months ago

Šaman
Member
Registered: 2010-01-08
Location: Liberec
Posts: 1013

Re: Building First Application

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


PHP mě živí: Pivo – Houska – Paprikáš

 

26. 3 months ago

DavidTheNewbie
Member
Registered: 2014-01-19
Posts: 8

Re: Building First Application

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)

 

Board footer

Switch to desktop