# Warning in laminas\\laminas-router regex

**URL:** <https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129>\
**Category:** Components & MVC\
**Tags:** laminas-router\
**Created:** [February 24, 2021, 2:43pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129 "2021-02-24T14:43:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthieu-antoniol](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthieu-antoniol/32/912_2.png) [@matthieu-antoniol](https://discourse.laminas.dev/u/matthieu-antoniol)\
**Post date:** [February 24, 2021, 2:43pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129/1 "2021-02-24T14:43:33Z")

</div>

Hello,

I’m currently migrating from old zend framework to laminas.  
I have been lead to use laminas-router.

Since i installed the library in version 3.4.4 (latest stable if i’m not wrong), I have been having the following warning:

> PHP Warning: preg\_match(): No ending matching delimiter ‘)’ found in /_path-to-vendors_/vendor/laminas/laminas-router/src/Http/Hostname.php on line 298

I went to check the line here is what i found:

`$result = preg_match('(^' . $this->regex . '$)', $host, $matches);`

Any idea on how to remove those warning?

Thank you very much

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [February 24, 2021, 3:12pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129/2 "2021-02-24T15:12:24Z")

</div>

Hello and welcome to our forums! 😃

> [@matthieu-antoniol](#):
>
> Any idea on how to remove those warning?

Can you provide the related route definition for the Hostname route? This will help to reproduce the problem. Thanks!

And please check the following if there are errors:

```auto
$route = new Laminas\Router\Http\Hostname('example.com');
$request = new Laminas\Http\Request();

$request->setUri('http://example.com');
var_dump($route->match($request)); // Laminas\Router\Http\RouteMatch

$request->setUri('http://example.de');
var_dump($route->match($request)); // null

```

---

<div class="post-metadata">

**Author:** ![matthieu-antoniol](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthieu-antoniol/32/912_2.png) [@matthieu-antoniol](https://discourse.laminas.dev/u/matthieu-antoniol)\
**Post date:** [February 24, 2021, 3:45pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129/3 "2021-02-24T15:45:34Z")

</div>

Hello thank you for welcoming me.

How can i find or provide you the route definition?

I tested what you asked.  
I used a print of get\_class instead of var\_dump but i think it doesnt matter.  
get\_class($route-\>match($request))

This part:

> $request-\>setUri(‘[http://example.com](http://example.com)’);  
> var\_dump($route-\>match($request));

Returned an object of class Laminas\Router\Http\RouteMatch

This part:

> $request-\>setUri(‘[http://example.de](http://example.de)’);  
> var\_dump($route-\>match($request));

Returned null

So no Error in the end. My message is about a warning that doesn’t really make php bug.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [February 24, 2021, 3:52pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129/4 "2021-02-24T15:52:00Z")

</div>

> [@matthieu-antoniol](#):
>
> How can i find or provide you the route definition?

If your application is based on laminas-mvc and you have followed the standard directory structure, then it is defined in the configuration. For example in the file `/modules/Application/config/module.config.php`:

> <https://github.com/laminas/laminas-mvc-skeleton/blob/12ff936b69caf63797b9c06a9f3a5d95482be913/module/Application/config/module.config.php#L18-L41>

See also the documentation or the getting started tutorial:

> **[Quick Start - laminas-mvc - Laminas Docs](https://docs.laminas.dev/laminas-mvc/quick-start/#create-a-route)**
>
> Laminas' event-driven MVC layer, including MVC Applications, Controllers, and Plugins.

> **[Routing and Controllers - tutorials - Laminas Docs](https://docs.laminas.dev/tutorials/getting-started/routing-and-controllers/)**
>
> Learn how to create laminas-mvc applications, get in-depth guides into components, and discover how to migrate your applications to version 3!

---

<div class="post-metadata">

**Author:** ![matthieu-antoniol](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthieu-antoniol/32/912_2.png) [@matthieu-antoniol](https://discourse.laminas.dev/u/matthieu-antoniol)\
**Post date:** [February 24, 2021, 4:05pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129/5 "2021-02-24T16:05:51Z")

</div>

Ok i see which part you mean.

Sadly i got 7 modules with a tone of routes and childroutes.  
Those routes contains quite sensitive structural information about my application.

Anything in particular you want to check?

```
    'router' => [
            'routes' => [
                'application' => [
                    'type' => Hostname::class,
                    'options' => [
                        'route' => '[:fulldomain]',
                        'constraints' => [
                            'fulldomain' => 'application.*'
                        ],
                        'defaults' => [
                            ' __NAMESPACE__' => 'Application\Controller',
                            'controller' => 'Index',
                            'action' => 'index',
                        ],
                    ],
                    'may_terminate' => true,
                    'child_routes' => [....... Lots of child routes ...]],
    ],
],

```

It is an anonymized subset of the routing system i was testing.

Thank you again for your help.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [February 24, 2021, 6:35pm UTC](https://discourse.laminas.dev/t/warning-in-laminas-laminas-router-regex/2129/6 "2021-02-24T18:35:40Z")

</div>

> [@matthieu-antoniol](#):
>
> Sadly i got 7 modules with a tone of routes and childroutes.

The error message comes from the Hostname route, so all of these should be checked. This means we need all entries with the type `Laminas\Router\Http\Hostname::class`.

The route from your code example works:

```auto
$route = new Laminas\Router\Http\Hostname(
    '[:fulldomain]',
    [
        'fulldomain' => 'application.*',
    ]
);
$request = new Laminas\Http\Request();

$request->setUri('http://application.example.com');
var_dump($route->match($request)); // Laminas\Router\Http\RouteMatch

$request->setUri('http://application.com');
var_dump($route->match($request)); // Laminas\Router\Http\RouteMatch

$request->setUri('http://application.com/album/list');
var_dump($route->match($request)); // Laminas\Router\Http\RouteMatch

```

You can use a debugger that shows the current values when the error message occurs.
