Giter Site home page Giter Site logo

routing's Introduction

Nette Framework is a popular tool for PHP web development. It is designed to be as usable and as friendly as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks.

Nette Framework speaks your language and helps you to easily build better websites.

The Quick Start tutorial gives you a first introduction to the framework by creating a simple database driven application.

Over 10 Yrs of Development

We have been developing Nette for over 10 years- and counting! Libraries we provide are therefore highly mature, stable and widely used. They are trusted by a number of global corporations and many significant websites rely on us.

Catching Bronze

We aim to create Nette as a fun and easy to use framework, that programmers can fall in love with. And we seem to be doing it well! We were rated as the 3rd most popular framework in a survey Best PHP Framework for 2015 by a well-know magazine SitePoint.

Security Is a Priority

There is nothing we care about more than security. That is why we had built Nette as the safest PHP framework. It had passed many audits with flying colours, it eliminates safety traps like XSS, CSRF and brings out ground-breaking methods.

Libraries & Framework

Nette consists of a number of handy standalone libraries, which can be used in any codebase, for example combined with WordPress or another framework. Careful, some of them are highly addictive! These are the components that Nette Framework is built on:

  • Application – The kernel of web application
  • Bootstrap – Bootstrap of your application
  • Caching – Cache layer with set of storages
  • Component Model – Foundation for component systems
  • DI – Dependency Injection Container
  • Finder – Find files and directories with an intuitive API
  • Database – Database layer
  • Forms – Greatly facilitates secure web forms
  • Http – Layer for the HTTP request & response
  • Latte – Amazing template engine
  • Mail – Sending E-mails
  • Neon – Loads and dumps NEON format
  • Php Generator – PHP code generator
  • Robot Loader – The most comfortable autoloading
  • Routing – Routing
  • Safe Stream – Safe atomic operations with files
  • Security – Provides access control system
  • Schema – User data validation
  • Tester – Enjoyable unit testing in PHP
  • Tracy – Debugging tool you will love ♥
  • Tokenizer – Source code tokenizer
  • Utils – Utilities and Core Classes

routing's People

Contributors

dakorpar avatar davidkrmela avatar dg avatar enumag avatar fabik avatar fprochazka avatar jangalek avatar jantvrdik avatar lopo avatar majkl578 avatar michalwiglasz avatar paranoiq avatar pavelkucera avatar richard-ejem avatar tomaswindsor avatar trejjam avatar vlastavesely avatar voda avatar vrana avatar xificurk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

routing's Issues

withPath does not match path without ending slash

Version: dev-master

Bug Description

Different behavior of matching path and path/

Steps To Reproduce

$list = new RouteList();
$list->withPath('admin')
	->addRoute('[<presenter>]');
$list->addRoute('[<presenter>]');

var_dump($list->match(new Request(new UrlScript('http://localhost/admin/')))); // first route match
var_dump($list->match(new Request(new UrlScript('http://localhost/admin')))); // second route match

Expected Behavior

Both cases match first route

RouteList should define domain prefix

Very often I need to define a group of routes that have a common prefix in a single RouteList.

For example locale:

$router = new RouteList('Front');
$router->addRoute('https://%host%/<locale>/<presenter>/<action>', ...);

Now there is no easy way to set a common prefix for all routes in a domain (module).

It could be set as a RouteList second argument:

$router = new RouteList('Front', 'https://%host%/<locale>/');
$router->addRoute('<presenter>/<action>', ...);

Thanks.

Showing commas in URL parameter

If a variable containing commas is used in the URL, these commas are changed to the encoded version. For example this:

$router->withModule('Front')->addRoute('/tags[:<slugs>]', [
	'presenter' => 'Tag',
	'action' => 'default',
]);

with string variable "music,sports" generates this: www.example.com/tags:music%2Csports

It would be great to be able to keep the commas in their original form and make a nice URL like: www.example.com/tags:music,sports

Would it be please possible to change the router accordingly?

Add prependRoute method

Hi,

in ErrorPresenter I create catchall route looking like this [<url .*>] to get {link this} or {link 404!} working in the error template. But I need to prepend it to avoid the request being consumed by another route (looking like this <presenter>/<action>[/<id>] for example). I need to avoid using Route constructor that's why I can't use prepend method which needs it (every RouteList can use different Route class). I need to create the route in a way addRoute method is doing this. If you think it is a good idea, I can create PR. Thank you.

Global prefix via route list

  • bug report? no
  • feature request? yes

Description

Recently, I've created many multi-domain sites and routing was painful.
I think the route list can be the smartest than a simple array of routes and cache.
There's my idea about prefix system.

Before:

$sectionDomain = '//section.example.com/';
$presentationDomain = '//example.com/';

$router = new RouteList;

$router[] = $section = new RouteList('Section');
$router[] = $presentation = new RouteList('Presentation');

// Register presentation home
$presentation[] = new Route($presentationDomain, 'Home:default');

// Register home presenter
$section[] = new Route($sectionDomain, 'Home:default');

// Register login presenter
$section[] = new Route($sectionDomain . 'login', 'Login:fefault');
$section[] = new Route($sectionDomain . 'logout', 'Login:logout');

$section[] = new Route($sectionDomain . 'clanky', 'Articles:default');
$section[] = new Route($sectionDomain . 'novinky', 'News:default');

After:

$router = new RouteList;

$router[] = $section = new RouteList('Section', '//section.example.com/');
$router[] = $presentation = new RouteList('Presentation', '//example.com/');

// Register presentation home
$presentation[] = new Route('', 'Home:default');

// Register home presenter
$section[] = new Route('', 'Home:default');

// Register login presenter
$section[] = new Route('login', 'Login:fefault');
$section[] = new Route('logout', 'Login:logout');

$section[] = new Route('clanky', 'Articles:default');
$section[] = new Route('novinky', 'News:default');

InvalidLinkException when switching from Nette 2.4 to 3.0

Description

I'm migrating app to Nette v3 and I'm getting InvalidLinkException with No route for Auth:Sign:in(). The match() pass and presenter runs, but building links by constructUrl() fails.

Steps To Reproduce

Router factory looks like:

$router = new RouteList;
$router[] = new Route('auth/<presenter>[/<action>[/<id>]]', [
        'module' => 'Auth',
        'presenter' => 'Homepage',
        'action' => 'default',
]);
$router[] = new Route('<presenter>[/<action>[/<id>]]', [
        'module' => 'Default',
        'presenter' => 'Homepage',
        'action' => 'default',
]);

and I had to rewrite routes as follow to get it work.

$router = new RouteList;
$router->withModule('Auth')->addRoute('auth/<presenter>[/<action>[/<id>]]', [
        'presenter' => 'Homepage',
        'action' => 'default',
]);
$router->withModule('Default')->addRoute('<presenter>[/<action>[/<id>]]', [
        'presenter' => 'Homepage',
        'action' => 'default',
]);

I digged out to

$key = $params[$this->cacheKey] ?? null;
if (!is_scalar($key) || !isset($this->ranks[$key])) {
$key = '*';
}
and found, that $key = null because $params['module'] is not set and $params['presenter'] === 'Auth:Sign' for example.

Not sure it is an intention.

Bug: Canonical logic accept domain.com/////

  • bug report? yes
  • feature request? yes
  • version: v3.0.0

Description

In case of domain.com//// internal method match(IRequest $httpRequest): ?array got fake URL with only one slash.

Some example (CustomRouter.php):

public function match(IRequest $httpRequest): ?array
{
	$url = $httpRequest->getUrl();
	dump($url);
	dump($url->getAbsoluteUrl());
	$realUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http')
		. '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	dump($realUrl);
	die;

In production mode dump looks like this:

Snímek obrazovky 2020-02-12 v 10 05 47

So object UrlScript contains invalid URL and I can open URL https://nette.org, https://nette.org/ and https://nette.org///// too without canonical redirect.

Steps To Reproduce

Open https://nette.org///// for example:

Snímek obrazovky 2020-02-12 v 10 08 39

Thanks.

Missing mechanism to parameters value comparison without referencing

  • bug report? yes
  • feature request? yes
  • version: all

Description

In Route.php#L220 is used === to compare parameters. If used ENUMs or ValueObjects as a parameter with usage of (re)storeRequest or (de)serialization or clone, the result can never be true.

Missing mechanism to value comparison without referencing like Equalable utils.

Steps To Reproduce

$classA = new \stdClass();

$classB = clone $classA;
\Tester\Assert::equal($classA, $classB);	// true
\Tester\Assert::true($classA == $classB);	// true
\Tester\Assert::true($classA === $classB);	// false

$classC = unserialize(serialize($classA));
\Tester\Assert::equal($classA, $classC);	// true
\Tester\Assert::true($classA == $classC);	// true
\Tester\Assert::true($classA === $classC);	// false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.