Coder Social home page Coder Social logo

router-fastroute's Introduction

Yii Router FastRoute adapter


Latest Stable Version Total Downloads Build status Code Coverage Mutation testing badge static analysis type-coverage

The package provides FastRoute adapter for Yii Router.

Requirements

  • PHP 8.0 or higher.

Installation

The package could be installed with composer:

composer require yiisoft/router-fastroute

General usage

The package is not meant to be used separately so check Yii Router readme for general usage and FastRoute for pattern syntax.

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii Router FastRoute adapter is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

router-fastroute's People

Contributors

arhell avatar dependabot-preview[bot] avatar dependabot[bot] avatar devanych avatar fantom409 avatar gerych1984 avatar hiqsol avatar kamarton avatar machour avatar mister-42 avatar nex-otaku avatar roxblnfk avatar rustamwin avatar samdark avatar sankaest avatar silverfire avatar stylecibot avatar terabytesoftw avatar thenotsoft avatar viktorprogger avatar vjik avatar xepozz avatar yiiliveext 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

Watchers

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

router-fastroute's Issues

Localization don't work without `CurrentRoute`

Test fails:

$urlGenerator = $this->createUrlGenerator([
	Route::get('/home/index')->name('index'),
]);
$urlGenerator->setLocaleParameterName('_locale');
$urlGenerator->setLocales(['uz' => 'uz-UZ', 'en' => 'en-US', 'ru' => 'ru-RU']);

$url = $urlGenerator->generate('index', ['_locale' => 'uz']);

$this->assertEquals('/uz/home/index', $url);

Remove not substituted arguments

Proposal to not add not substituted arguments if they a not in route. I think this not need here, in UrlGenerator::generate() has the separate argument for query string. If it ok, I can make PR.

return $path . (
$notSubstitutedArguments !== [] || $queryParameters !== [] ?
'?' . http_build_query(array_merge($notSubstitutedArguments, $queryParameters))
: ''

What steps will reproduce the problem?

// routes
Route::get('/view/{mode}')->name('view');
$urlGenerator->setDefaultParameter('mode', 'simple');
$urlGenerator->setDefaultParameter('type', 'any');

$urlGenerator->generate('view');

What is the expected result?

/view/simple

What do you get instead?

/view/simple?type=any

Additional info

Q A
Version 3.0.0
PHP version 8.0
Operating system

UrlGenerator::generate and UrlGenerate::generateAbsolute with nested $parameters arguments.

Good day. After last releases methods generate and generateAbsolute was failed on that string $parameters = array_map('\strval', $parameters); if send multilevel array like this (generated from Yiisoft\Form\FormModel attributes)

[
    'Search' => [
        'address.with_data' => false
        'address.objects.type_ids' => [
            0 => '4'
        ]
        'address.objects.is_active' => true
        'address.pageData.page.source_ids' => [
            0 => '6'
        ]
    ]
]

Groups works incorrect

What steps will reproduce the problem?

Add into RouterFactory

        $router = (new RouterFactory(new FastRouteFactory(), $routes))($container);
        $router->addGroup('/blog', static function (RouteCollectorInterface $r) use (&$container) {
            $r->addRoute(
                Route::get('/index')
                     ->to(new ActionCaller(SiteController::class, 'index', $container))
                     ->name('blog/index')
            );
        });
        return $router;

Go to /blog/index

What is the expected result?

Response with HTTP 200 and index page

What do you get instead?

Response with HTTP 405

Additional info

Works strange with next code:

$router->addGroup('/blog', ... $r->addRoute(Route::get('/') ...) # /blog/

Performs as path /

route with default parameters and null for generate

What steps will reproduce the problem?

For the code below, I would expect to use the default value when I use NULL when generating.

        $routes = [
            Route::get('/view/{test:\w+}')->name('view')->defaults([
                'test' => 'test'
            ]),
        ];
        $routerCollector = $this->createRouterCollector($routes);

        $url = $routerCollector->generate('view', ['test' => null]);

        $this->assertEquals('/view/test', $url);

this would be particularly useful for the following uses:

$url = $routerCollector->generate('view', ['name' => $any->name ?? null]);

What is the expected result?

success

What do you get instead?

RuntimeException: Route `view` expects at least parameter values for [test], but received [test]

Additional info

Q A
Version 3.0.x-dev
PHP version -
Operating system -

update irc link

What steps will reproduce the problem?

What is the expected result?

What do you get instead?

Additional info

Q A
Version 1.0.?
PHP version
Operating system

Unnecessary question mark

What steps will reproduce the problem?

Route::get('/articles')->name('article')

$urlGenerator->generate('article', [], ['query' => null])

What is the expected result?

/articles

What do you get instead?

/articles?
'?' at the end url

Additional info

Q A
Version 3.0.?
PHP version 8.0
Operating system Linux

Use incorrect key in params

Now use yiisoft/router, should be yiisoft/router-fastroute.

See docs:

Parameters should be namespaced with vendor/package-name

Error while route generating

What steps will reproduce the problem?

Config routes
DeepinScreenshot_выберите-область_20191107232550
DeepinScreenshot_выберите-область_20191107233150

What is the expected result?

Url successfully generated

What do you get instead?

Error
DeepinScreenshot_выберите-область_20191107232658

Additional info

DeepinScreenshot_выберите-область_20191107232757
DeepinScreenshot_выберите-область_20191107232728

Q A
Version last
PHP version 7.2
Operating system Linux

generateAbsolute not creating correct URL

What steps will reproduce the problem?

config/routes.php

Route::get('/images/{file}')
    ->name('images')
    ->host('example.com'),

view

var_dump($url->generateAbsolute('images', ['file' => 'test.png']));

What is the expected result?

string(29) "//example.com/images/test.png"

What do you get instead?

string(27) "example.com/images/test.png"

Additional info

Q A
Version dev
PHP version 8.0.0
Operating system Debian 10

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.