Problem Z Kodem W Yii

Witam, podczas robienia tutoriala z yii, gdy chcę otworzyć: //hostname/testdrive/index.php?r=gii wyskakuje mi błąd: [b]Parse error: syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) in C:\xampp\htdocs\blog\protected\config\main.php on line 30

[/b]

oto mój cały kod:

<?php

// uncomment the following to define a path alias

// Yii::setPathOfAlias(‘local’,‘path/to/local-folder’);

// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

'basePath'=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


'name'=&gt;'My Web Application',





// preloading 'log' component


'preload'=&gt;array('log'),





// autoloading model and component classes


'import'=&gt;array(


    'application.models.*',


    'application.components.*',


),





'modules'=&gt;array(


    'gii'=&gt;array(


        'class'=&gt;'system.gii.GiiModule',


        'password'=&gt;'1234',


    ),


),

);

// application components


'components'=&gt;array(

),

	'user'=&gt;array(


		// enable cookie-based authentication


		'allowAutoLogin'=&gt;true,


	),


	// uncomment the following to enable URLs in path-format


	/*


	'urlManager'=&gt;array(


		'urlFormat'=&gt;'path',


		'rules'=&gt;array(


			'&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


		),


	),


	*/


	'db'=&gt;array(


		'connectionString' =&gt; 'sqlite:'.dirname(__FILE__).'/&#46;&#46;/data/testdrive.db',


	),


	// uncomment the following to use a MySQL database


	/*


	'db'=&gt;array(


		'connectionString' =&gt; 'mysql:host=localhost;dbname=testdrive',


		'emulatePrepare' =&gt; true,


		'username' =&gt; 'root',


		'password' =&gt; '',


		'charset' =&gt; 'utf8',


	),


	*/


	'errorHandler'=&gt;array(


		// use 'site/error' action to display errors


		'errorAction'=&gt;'site/error',


	),


	'log'=&gt;array(


		'class'=&gt;'CLogRouter',


		'routes'=&gt;array(


			array(


				'class'=&gt;'CFileLogRoute',


				'levels'=&gt;'error, warning',


			),


			// uncomment the following to show log messages on web pages


			/*


			array(


				'class'=&gt;'CWebLogRoute',


			),


			*/


		),


	),


),





// application-level parameters that can be accessed


// using Yii::app()-&gt;params['paramName']


'params'=&gt;array(


	// this is used in contact page


	'adminEmail'=&gt;'webmaster@example.com',


),

);

Masz błędnie zadeklarowaną tablicę - w okolicach 27 linii masz nawias i średnik zamykające tablicę, a później deklarujesz ją sobie dalej. Tej linijki prawdopodobnie w ogóle tu nie powinno być.

W ogóle masz bałagan z tą tablicą, zawartość "components" jest deklarowana poza elementem "components", a dalej już nawet nie sprawdzałem. Skorzystaj może z jakiegoś IDE podpowiadającego składnię i ułatwiającego formatowanie, bo bez uporządkowanych wcięć będziesz miał z tym tylko same problemy.

Zacząłem poprawić więc wrzucam poprawiony main.php, jak kolega wspomniał, pilnuj nawiasów i formatowania kodu a w postach dla wklejanego kodu używaj odpowiednich tagów "Other styles"


<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

    'name' => 'My Web Application',


    // preloading 'log' component

    'preload' => array('log'),


    // autoloading model and component classes

    'import' => array(

        'application.models.*',

        'application.components.*',

    ),


    'modules' => array(

        'gii' => array(

            'class' => 'system.gii.GiiModule',

            'password' => '1234',

        ),

    ),


    // application components

    'components' => array(),


    'user' => array(

        // enable cookie-based authentication

        'allowAutoLogin' => true,

    ),


// uncomment the following to enable URLs in path-format

    /*

    'urlManager'=>array(

    'urlFormat'=>'path',

    'rules'=>array(

    '<controller:\w+>/<id:\d+>'=>'<controller>/view',

    '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

    ),

    ),

    */


    'db' => array(

        'connectionString' => 'sqlite:' . dirname(__FILE__) . '/../data/testdrive.db',

    ),


    // uncomment the following to use a MySQL database

    /*

    'db'=>array(

    'connectionString' => 'mysql:host=localhost;dbname=testdrive',

    'emulatePrepare' => true,

    'username' => 'root',

    'password' => '',

    'charset' => 'utf8',

    ),

    */


    'errorHandler' => array(

        // use 'site/error' action to display errors

        'errorAction' => 'site/error',

    ),


    'log' => array(

        'class' => 'CLogRouter',

        'routes' => array(

            array(

                'class' => 'CFileLogRoute',

                'levels' => 'error, warning',

            ),

            // uncomment the following to show log messages on web pages

            /*

            array(

            'class'=>'CWebLogRoute',

            ),

            */

        ),

    ),


    'params' => array(

        // this is used in contact page

        'adminEmail' => 'webmaster@example.com',

    )


// application-level parameters that can be accessed

// using Yii::app()->params['paramName']

);

Twój config jest ciągle nieprawidłowy - definiujesz komponenety poza elementem "components".

Niestety, po wklejeniu kodu od Ciebie Viktor wyświetla mi się następująca rzecz ( w załączniku screeny5628

nafor1.jpg

No faktycznie jeszcze jeden nawias :), teraz powinno być dobrze.


<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');


// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

    'name' => 'My Web Application',


    // preloading 'log' component

    'preload' => array('log'),


    // autoloading model and component classes

    'import' => array(

        'application.models.*',

        'application.components.*',

    ),


    'modules' => array(

        'gii' => array(

            'class' => 'system.gii.GiiModule',

            'password' => '1234',

        ),

    ),


    // application components

    'components' => array(

        'user' => array(

            // enable cookie-based authentication

            'allowAutoLogin' => true,

        ),


        // uncomment the following to enable URLs in path-format

        /*

        'urlManager'=>array(

        'urlFormat'=>'path',

        'rules'=>array(

        '<controller:\w+>/<id:\d+>'=>'<controller>/view',

        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

        ),

        ),

        */


        'db' => array(

            'connectionString' => 'sqlite:' . dirname(__FILE__) . '/../data/testdrive.db',

        ),


        // uncomment the following to use a MySQL database

        /*

        'db'=>array(

        'connectionString' => 'mysql:host=localhost;dbname=testdrive',

        'emulatePrepare' => true,

        'username' => 'root',

        'password' => '',

        'charset' => 'utf8',

        ),

        */


        'errorHandler' => array(

            // use 'site/error' action to display errors

            'errorAction' => 'site/error',

        ),


        'log' => array(

            'class' => 'CLogRouter',

            'routes' => array(

                array(

                    'class' => 'CFileLogRoute',

                    'levels' => 'error, warning',

                ),

                // uncomment the following to show log messages on web pages

                /*

                array(

                'class'=>'CWebLogRoute',

                ),

                */

            ),

        ),

    ),


    'params' => array(

        // this is used in contact page

        'adminEmail' => 'webmaster@example.com',

    )


    // application-level parameters that can be accessed

    // using Yii::app()->params['paramName']

);

Dziękuję VIKTOR. Działa. Od razu robię kopię:) Dziękuję Ci serdecznie, dopiero się uczę:)

Do poprawiania błędów składni używaj IDE a nie forum, to bardzo podstawowa czynność. Oszczędzisz dużo czasu.