├── .htaccess ├── app ├── Bootstrap.php ├── Core │ └── RouterFactory.php └── Presentation │ ├── @layout.latte │ ├── Accessory │ └── LatteExtension.php │ ├── Error │ ├── Error4xx │ │ ├── 403.latte │ │ ├── 404.latte │ │ ├── 410.latte │ │ ├── 4xx.latte │ │ └── Error4xxPresenter.php │ └── Error5xx │ │ ├── 500.phtml │ │ ├── 503.phtml │ │ └── Error5xxPresenter.php │ └── Home │ ├── HomePresenter.php │ └── default.latte ├── assets └── main.js ├── composer.json ├── config ├── common.neon └── services.neon ├── package.json ├── phpstan.neon ├── readme.md ├── vite.config.ts └── www ├── .htaccess ├── favicon.ico ├── index.php └── robots.txt /.htaccess: -------------------------------------------------------------------------------- 1 | Require all denied 2 | -------------------------------------------------------------------------------- /app/Bootstrap.php: -------------------------------------------------------------------------------- 1 | rootDir = dirname(__DIR__); 20 | $this->configurator = new Configurator; 21 | $this->configurator->setTempDirectory($this->rootDir . '/temp'); 22 | } 23 | 24 | 25 | public function bootWebApplication(): Nette\DI\Container 26 | { 27 | $this->initializeEnvironment(); 28 | $this->setupContainer(); 29 | return $this->configurator->createContainer(); 30 | } 31 | 32 | 33 | public function initializeEnvironment(): void 34 | { 35 | //$this->configurator->setDebugMode('secret@23.75.345.200'); // enable for your remote IP 36 | $this->configurator->enableTracy($this->rootDir . '/log'); 37 | 38 | $this->configurator->createRobotLoader() 39 | ->addDirectory(__DIR__) 40 | ->register(); 41 | } 42 | 43 | 44 | private function setupContainer(): void 45 | { 46 | $configDir = $this->rootDir . '/config'; 47 | $this->configurator->addConfig($configDir . '/common.neon'); 48 | $this->configurator->addConfig($configDir . '/services.neon'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/Core/RouterFactory.php: -------------------------------------------------------------------------------- 1 | addRoute('/[/]', 'Home:default'); 19 | return $router; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Presentation/@layout.latte: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {ifset title}{include title|stripHtml} | {/ifset}Nette Web 8 | 9 | {asset? 'main.js'} 10 | 11 | 12 | 13 |
{$flash->message}
14 | 15 | {include content} 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/Presentation/Accessory/LatteExtension.php: -------------------------------------------------------------------------------- 1 | Access Denied 3 | 4 |

You do not have permission to view this page. Please try contact the web 5 | site administrator if you believe you should be able to view this page.

6 | 7 |

error 403

8 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error4xx/404.latte: -------------------------------------------------------------------------------- 1 | {block content} 2 |

Page Not Found

3 | 4 |

The page you requested could not be found. It is possible that the address is 5 | incorrect, or that the page no longer exists. Please use a search engine to find 6 | what you are looking for.

7 | 8 |

error 404

9 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error4xx/410.latte: -------------------------------------------------------------------------------- 1 | {block content} 2 |

Page Not Found

3 | 4 |

The page you requested has been taken off the site. We apologize for the inconvenience.

5 | 6 |

error 410

7 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error4xx/4xx.latte: -------------------------------------------------------------------------------- 1 | {block content} 2 |

Oops...

3 | 4 |

Your browser sent a request that this server could not understand or process.

5 | 6 |

error {$httpCode}

7 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error4xx/Error4xxPresenter.php: -------------------------------------------------------------------------------- 1 | getCode(); 21 | $file = is_file($file = __DIR__ . "/$code.latte") 22 | ? $file 23 | : __DIR__ . '/4xx.latte'; 24 | $this->template->httpCode = $code; 25 | $this->template->setFile($file); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error5xx/500.phtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Server Error 5 | 6 | 13 | 14 |
15 |
16 |

Server Error

17 | 18 |

We're sorry! The server encountered an internal error and 19 | was unable to complete your request. Please try again later.

20 | 21 |

error 500

22 |
23 |
24 | 25 | 28 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error5xx/503.phtml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 19 | 20 | Site is temporarily down for maintenance 21 | 22 |

We're Sorry

23 | 24 |

The site is temporarily down for maintenance. Please try again in a few minutes.

25 | -------------------------------------------------------------------------------- /app/Presentation/Error/Error5xx/Error5xxPresenter.php: -------------------------------------------------------------------------------- 1 | getParameter('exception'); 30 | $this->logger->log($exception, ILogger::EXCEPTION); 31 | 32 | // Display a generic error message to the user 33 | return new Responses\CallbackResponse(function (Http\IRequest $httpRequest, Http\IResponse $httpResponse): void { 34 | if (preg_match('#^text/html(?:;|$)#', (string) $httpResponse->getHeader('Content-Type'))) { 35 | require __DIR__ . '/500.phtml'; 36 | } 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Presentation/Home/HomePresenter.php: -------------------------------------------------------------------------------- 1 | 5 |

Congratulations!

6 | 7 | 8 |
9 |

You have successfully created your Nette Web project.

10 | 11 |

12 | If you are exploring Nette for the first time, you should read the 13 | Quick Start, documentation, 14 | blog and forum.

15 | 16 |

We hope you enjoy Nette!

17 |
18 | 19 | 39 | -------------------------------------------------------------------------------- /assets/main.js: -------------------------------------------------------------------------------- 1 | // Initialize Nette Forms on page load 2 | import netteForms from 'nette-forms'; 3 | 4 | netteForms.initOnLoad(); 5 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nette/web-project", 3 | "description": "Nette: Standard Web Project", 4 | "keywords": ["nette"], 5 | "type": "project", 6 | "license": ["MIT", "BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only"], 7 | "require": { 8 | "php": ">= 8.1", 9 | "nette/application": "^3.2.3", 10 | "nette/assets": "^1.0.0", 11 | "nette/bootstrap": "^3.2.6", 12 | "nette/caching": "^3.2", 13 | "nette/database": "^3.2", 14 | "nette/di": "^3.2", 15 | "nette/forms": "^3.2", 16 | "nette/http": "^3.3", 17 | "nette/mail": "^4.0", 18 | "nette/robot-loader": "^4.0", 19 | "nette/security": "^3.2", 20 | "nette/utils": "^4.0", 21 | "latte/latte": "^3.0", 22 | "tracy/tracy": "^2.10" 23 | }, 24 | "require-dev": { 25 | "nette/tester": "^2.5", 26 | "phpstan/phpstan-nette": "^2", 27 | "symfony/thanks": "^1" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "App\\": "app" 32 | } 33 | }, 34 | "scripts": { 35 | "phpstan": "phpstan analyse", 36 | "tester": "tester tests -s" 37 | }, 38 | "minimum-stability": "stable", 39 | "config": { 40 | "allow-plugins": { 41 | "symfony/thanks": true 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /config/common.neon: -------------------------------------------------------------------------------- 1 | # see https://doc.nette.org/en/configuring 2 | 3 | parameters: 4 | 5 | 6 | application: 7 | errorPresenter: 8 | 4xx: Error:Error4xx 9 | 5xx: Error:Error5xx 10 | mapping: App\Presentation\*\**Presenter 11 | 12 | 13 | database: 14 | dsn: 'sqlite::memory:' 15 | user: 16 | password: 17 | 18 | 19 | latte: 20 | strictTypes: yes 21 | strictParsing: yes 22 | extensions: 23 | - App\Presentation\Accessory\LatteExtension 24 | 25 | 26 | assets: 27 | mapping: 28 | default: 29 | path: assets 30 | # type: vite # Uncomment to activate Vite for asset building 31 | 32 | 33 | di: 34 | export: 35 | parameters: no 36 | tags: no 37 | -------------------------------------------------------------------------------- /config/services.neon: -------------------------------------------------------------------------------- 1 | services: 2 | - App\Core\RouterFactory::createRouter 3 | 4 | 5 | search: 6 | - in: %appDir% 7 | classes: 8 | - *Facade 9 | - *Factory 10 | - *Repository 11 | - *Service 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "dependencies": { 4 | "nette-forms": "^3.3" 5 | }, 6 | "devDependencies": { 7 | "@nette/vite-plugin": "^1.0.1", 8 | "vite": "^6.3.5" 9 | }, 10 | "scripts": { 11 | "dev": "vite", 12 | "build": "vite build" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 5 3 | 4 | paths: 5 | - src 6 | - bin 7 | - tests 8 | 9 | includes: 10 | - vendor/phpstan/phpstan-nette/extension.neon 11 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Nette Web Project 2 | ================= 3 | 4 | Welcome to the Nette Web Project! This is a basic skeleton application built using 5 | [Nette](https://nette.org), ideal for kick-starting your new web projects. 6 | 7 | Nette is a renowned PHP web development framework, celebrated for its user-friendliness, 8 | robust security, and outstanding performance. It's among the safest choices 9 | for PHP frameworks out there. 10 | 11 | If Nette helps you, consider supporting it by [making a donation](https://nette.org/donate). 12 | Thank you for your generosity! 13 | 14 | 15 | Requirements 16 | ------------ 17 | 18 | This Web Project is compatible with Nette 3.2 and requires PHP 8.1. 19 | 20 | 21 | Installation 22 | ------------ 23 | 24 | To install the Web Project, Composer is the recommended tool. If you're new to Composer, 25 | follow [these instructions](https://doc.nette.org/composer). Then, run: 26 | 27 | composer create-project nette/web-project path/to/install 28 | cd path/to/install 29 | 30 | Ensure the `temp/` and `log/` directories are writable. 31 | 32 | 33 | Asset Building with Vite 34 | ------------------------ 35 | 36 | This project supports Vite for asset building, which is recommended but optional. To activate Vite: 37 | 38 | 1. Uncomment the `type: vite` line in the `common.neon` configuration file under the assets mapping section. 39 | 2. Then set up and build the assets: 40 | 41 | npm install 42 | npm run build 43 | 44 | 45 | Web Server Setup 46 | ---------------- 47 | 48 | To quickly dive in, use PHP's built-in server: 49 | 50 | php -S localhost:8000 -t www 51 | 52 | Then, open `http://localhost:8000` in your browser to view the welcome page. 53 | 54 | For Apache or Nginx users, configure a virtual host pointing to your project's `www/` directory. 55 | 56 | **Important Note:** Ensure `app/`, `config/`, `log/`, and `temp/` directories are not web-accessible. 57 | Refer to [security warning](https://nette.org/security-warning) for more details. 58 | 59 | 60 | Minimal Skeleton 61 | ---------------- 62 | 63 | For demonstrating issues or similar tasks, rather than starting a new project, use 64 | [minimal skeleton](https://github.com/nette/web-project/tree/minimal). 65 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import nette from '@nette/vite-plugin'; 3 | 4 | export default defineConfig({ 5 | plugins: [ 6 | nette({ 7 | input: 'main.js', 8 | }), 9 | ], 10 | 11 | build: { 12 | emptyOutDir: true, 13 | }, 14 | 15 | css: { 16 | devSourcemap: true, 17 | }, 18 | }); 19 | -------------------------------------------------------------------------------- /www/.htaccess: -------------------------------------------------------------------------------- 1 | # Apache configuration file (see https://httpd.apache.org/docs/current/mod/quickreference.html) 2 | 3 | # Allow access to all resources by default 4 | Require all granted 5 | 6 | # Disable directory listing for security reasons 7 | 8 | Options -Indexes 9 | 10 | 11 | # Enable pretty URLs (removing the need for "index.php" in the URL) 12 | 13 | RewriteEngine On 14 | 15 | # Uncomment the next line if you want to set the base URL for rewrites 16 | # RewriteBase / 17 | 18 | # Force usage of HTTPS (secure connection). Uncomment if you have SSL setup. 19 | # RewriteCond %{HTTPS} !on 20 | # RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 21 | 22 | # Permit requests to the '.well-known' directory (used for SSL verification and more) 23 | RewriteRule ^\.well-known/.* - [L] 24 | 25 | # Block access to hidden files (starting with a dot) and URLs resembling WordPress admin paths 26 | RewriteRule /\.|^\.|^wp-(login|admin|includes|content) - [F] 27 | 28 | # Return 404 for missing files with specific extensions (images, scripts, styles, archives) 29 | RewriteCond %{REQUEST_FILENAME} !-f 30 | RewriteRule \.(pdf|js|mjs|ico|gif|jpg|jpeg|png|webp|avif|svg|css|rar|zip|7z|tar\.gz|map|eot|ttf|otf|woff|woff2)$ - [L] 31 | 32 | # Front controller pattern - all requests are routed through index.php 33 | RewriteCond %{REQUEST_FILENAME} !-f 34 | RewriteCond %{REQUEST_FILENAME} !-d 35 | RewriteRule . index.php [L] 36 | 37 | 38 | # Enable gzip compression for text files 39 | 40 | AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json application/xml application/rss+xml image/svg+xml 41 | 42 | -------------------------------------------------------------------------------- /www/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nette/web-project/09e5da4bfbc17c199dd7974e6cc222a3854e08bc/www/favicon.ico -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | bootWebApplication(); 9 | $application = $container->getByType(Nette\Application\Application::class); 10 | $application->run(); 11 | -------------------------------------------------------------------------------- /www/robots.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nette/web-project/09e5da4bfbc17c199dd7974e6cc222a3854e08bc/www/robots.txt --------------------------------------------------------------------------------