yii2mod / yii2-timezone

Timezone detector
MIT License
15 stars 3 forks source link

Installation of the Extension fails #1

Closed aidonsnous closed 8 years ago

aidonsnous commented 8 years ago

Does the extension support DST ?

I am getting the below error when trying to install the extension:

C:\wamp\www\fget>composer require --prefer-dist yii2mod/yii2-timezone "*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package yii2mod/yii2-timezone could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

I tried put adding the extension manually but the application is giving error message saying

Class yii2mod\timezone\Timezone does not exist

What I did is :

  1. Added in composer "yii2mod/timezone":"*"
  2. I download the zip file decompressed it and rename the parent directory yii2mod and the directory in it timezone(it is in this directory that the class is)
  3. In web.php I added
  'components' => [
        'timezone' => [
            'class' => 'yii2mod\timezone\Timezone',
            'actionRoute' => '/site/timezone' //optional param - full path to page must be specified
        ],
  1. In sitecontroller I added in action function
 'timezone' => [
                'class' => 'yii2mod\timezone\TimezoneAction',
            ],
  1. added in web.php for boostrap ,'timezone' What is wrong?
ihorchepurnyi commented 8 years ago

Hi, i create new release for this extension today. Please, try again setup this ext via composer.

aidonsnous commented 8 years ago

I tried to install it again via composer here is what I get:

C:\wamp\www\fget>composer require --prefer-dist yii2mod/yii2-timezone "*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info

What about the support of DST ?

aidonsnous commented 8 years ago

One Idea that I got was to download the new release zip file, extract and replace the file in the folder vendor\yii2mod\timezone with these new file. Before replacing I found the folder timezone has been renamed to yii2-timezone I try to rename it back and the tried to reload the page got the error class not exists then I understand what was the problem because putting it back as yii2-timezone no error. After replacing when reloading the page in google chrome I can see this error :

The requested URL /site/timezone was not found on this server.

But in my sitecontroller here is the actions method:

 public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
            ],
            'timezone' => [
                'class' => 'yii2mod\timezone\TimezoneAction',
            ],
        ];
    }
ihorchepurnyi commented 8 years ago

Can't reproduce this error. Yesterday I tested this package on yii2-basic and everything worked without errors.

aidonsnous commented 8 years ago

While debbuging my code I suspect in timezone class this code:

 $.post("$actionRoute", {
                    timezone: timezone,
                    timezoneAbbr: timezoneAbbr,
                    timezoneOffset: -new Date().getTimezoneOffset() / 60
                });

Since $actionRoute is not $actionRoute is not an url but an action route passing it as an url to jquery ajax function is what is causing the error:

`public $actionRoute = '/site/timezone';`

it should be Yii::$app->urlManager->createUrl(['site/timezone']) passed here:

$.post("$actionRoute", If I try to set $this->actionRoute = Yii::$app->urlManager->createUrl(['site/timezone']); the page is being reloaded automatically without stopping. That where I am stuck for now since I don't understand the code that's creating js code well.

ihorchepurnyi commented 8 years ago

I see that the page is being reloaded automatically without stopping.

You have been redirected to the login page? It's maybe rbac, try to disable rbac module for site controller or add route to allow section of AccessControl

aidonsnous commented 8 years ago

Yeah I forgot to add it to allow section but now I've added but still getting :

The requested URL /site/timezone was not found on this server.

I also try to access one of the actions as $actionroute is set(I tried with site/index) but it could not work.

ihorchepurnyi commented 8 years ago

I update Timezone class, please update package via composer and check it.

aidonsnous commented 8 years ago

Thanks it is working but add use yii\helpers\Url; In Timezone class file to avoid error about Url::toroute method

ihorchepurnyi commented 8 years ago

oh, thanks. I forgot about it.