prchakal
(Paulo)
October 15, 2014, 6:10am
1
Hi,
Im migration my web site to Yii 2.0:
http://utilw.com/
The problem is when you navigate thought menus. On my Mac everything is working fine. But in production it is not working.
My createURL code:
<a href="<?php echo(\Yii::$app->urlManager->createUrl('/geradorCPF/index')); ?>" class="list-group-item">Gerador de CPF</a>
My routes/rules config:
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'home/index',
'gerador-cpf' => 'geradorCPF/index',
'gerador-cnpj' => 'geradorCNPJ/index',
]
],
My controller:
<?php
namespace app\controllers;
use Yii;
class GeradorCPFController extends SiteController
{
public function actionIndex()
{
return $this->render('index');
}
}
The strange thing is that:
http://utilw.com/home/index (this route is working):
Can anyone help me?
prchakal
(Paulo)
October 16, 2014, 4:51pm
3
Hi,
I have found the problem in Yii. See the image please:
https://www.dropbox.com/s/re5e22capkhoq7o/Screenshot%202014-10-16%2001.51.52.png?dl=0
The controller dont pass in 'preg_match" expression. Im using PHP 5.6 - I dont know if has relation between this facts.
When i access with upper case controller name dont work. But when i access with lower case works on apache but not on nginx.
evstevemd
(Stefano Mtangoo)
October 16, 2014, 7:00pm
4
Yii have strict naming for good reasons. Avoide names Like SomeNICEController instead use something like SomeNiceController where you use.in url …([’/some-nice/action’, ‘id’=>5])
prchakal
(Paulo)
October 16, 2014, 9:48pm
5
Hi,
Thanks for response.
I have renamed to "GeradorCpfController" and try access:
http://utilw.com/gerador-cpf/index
http://utilw.com/geradorcpf/index
http://utilw.com/geradorCpf/index
But not success.
I dont have any specific rules for it, i leave the default routes:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'home/index',
]
],
Have any ideias?
prchakal
(Paulo)
October 16, 2014, 10:56pm
6
I have tried another think in production: www.utilw.com
\Yii::$app->urlManager->createUrl('/gerador-cpf/index')
My rules now:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'home/index',
'/gerador-cpf-new' => 'gerador-cpf/index',
]
],
My controller:
<?php
namespace app\controllers;
use Yii;
class GeradorCpfController extends SiteController
{
public function actionIndex()
{
return $this->render($this->action->id);
}
}
If you access the site "www.utilw.com ", you will see the link "Gerador de CPF - NEW" that is the current code posted here.
I think that it is a bug
prchakal
(Paulo)
October 16, 2014, 11:14pm
7
The strange thing is:
Why on my mac with MAMP (apache) it works and on production (nginx) with documentation rules, it dont works?
http://www.yiiframework.com/doc-2.0/guide-start-installation.html
prchakal
(Paulo)
October 16, 2014, 11:25pm
8
Sorry, problem solved
Thanks to "Stefano Mtangoo", you are correct man.
The problem here is with GIT, when i rename file “GeradorCPF” to “GeradorCpf” git ignore this change when i update on my server
After see it on my server, i do the correct changes and now it is working.
evstevemd
(Stefano Mtangoo)
October 17, 2014, 12:33pm
9
prchakal:
Sorry, problem solved
Thanks to "Stefano Mtangoo", you are correct man.
The problem here is with GIT, when i rename file “GeradorCPF” to “GeradorCpf” git ignore this change when i update on my server
After see it on my server, i do the correct changes and now it is working.
Clicking the plus sign to add reputation does not hurt