Yii on shared hosting

hi there,

I use localhost for development, i have put yii in web in-accessible folder, and development is fine.Now if i want to upload this localhost project to a shared host.Do i upload yii folder and my project(webroot/application) to shared host or do i create the whole set up as created for localhost and then add project specific controller views & models…Please help

Thanks

Raffi

Before upload clean assets and protected/runtime

Upload the whole directory structure, with all views file and whatever.

Then give write permission (777) on protected/runtime and assets

That’s all.

P.S: welcome to the forum!

I will only add to zaccaria’s answer that putting Yii into web-accessible directory is not a good idea and therefore, you should avoid it, if it is only possible. There is a number of hosting services that do not allow user to do anything outside web-accessible directory and in this situation there is no other option left like to have both app and yii in the same folder.

On the other hand, if you have access to some folder outsite web-accessible directory on your hosting and if you are a bit experienced in Linux, consider reading and introducing solutions given in this Wiki article, for boosting security of your app up.

i found the answer. you need to setup the framework path in index.php of your webroot/webapp that it then the framework is accessible to your application.

Thanks

Hi,

I’ve uploaded Yii to my hosting, and I’s use modules in Yii.

After uploaded project, I can access to myhost.vn/beta/example (example is my project).

When I try to access into modules like: myhost.vn/beta/admin/exampleAdminTest, it bring me "Not Found, The requested URL xxxx was not found on this server."

Any idea? I’ve set mode 777 to assets and runtime for both directories

Regards,

try to check if it works with urlManager set to url (not to path).

If works, it means your host don’t accept .htaccess

If you’re localhost is on Windows and the server is on Linux, it may be a case-sensitive issue.

If I’m not mistaken, not found (404?) means an error directly from Apache or other server that is serving your hosting, not from Yii. That is why I would follow zaccaria’s advice on checking case sensitivity of your files / folders / path / url.

Try to put a simple HTML file in the folder, where you have your module and try to assess it directly by entering it’s path and filename do browser address bar. This should ensure you, if problem lies in Yii or in your server configuration or path structure.

I have a different problem, after uploaded the application & the framework, they work fine in the first access (homepage/index.php), but when user logged-in, it shows Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /home/myappname/public_html/protected/controllers/SiteController.php on line 57.

What is the meaning of that error? and how to solve it? is Yii not "compatible" with my web hosting (not a free hosting)? The application works just fine in localhost.

If you would post the code at that line you would get a better help…

So… check this - lmgtfy.com/?q=T_PAAMAYIM_NEKUDOTAYIM

:D

Sure mdomba. I have this action




	public function actionTable()

	{

		if($_POST)

		{

			$tname=explode('_',$_POST['tableName']);

			foreach($tname as $item){

				$table.=(string)ucwords($item);

			}

			

			$model=$table::model()->findAll();

		}


		// Shows tables of database

		$this->render('table',array(

			'model'=>$model,

		));

	}



in my SiteController without creating Site model. I want to show (in CGridView) table content choosen by user (dropDownList). Why the error only occur in my hosting, not in localhost? What is the best suggestion for doing this?

Your code is a bit strange to me…

The first time you use the variable $table you have ".=" that would mean that the value does already exist…

Did you check the value of that variable before the line with findAll() to see if you have a model named like that ?

According to this topic, i’ve try to change my controller like below




	public function actionTable()

	{

		if($_POST)

		{

                        $table='';

			$tname=explode('_',$_POST['tableName']);

			foreach($tname as $item){

				$table.=(string)ucwords($item);

			}

			

			//$model=$table::model()->findAll();

			$model=CActiveRecord::model($table)->findAll();

		}


		// Shows tables of database

		$this->render('table',array(

			'model'=>$model,

		));

	}



and it is working fine now. The main problem is PHP version in the hosting server doesn’t support double colon. And i’ve put variable $table=’’; in the first line like mdomba suggestion.

The view file:




<?php echo CHtml::beginForm(); ?>


	Select Table Name:

	<?php echo CHtml::dropDownList('tableName',$_POST['tableName'],array(

				'akun'=>'akun',

				'kategori_akun'=>'kategori_akun',

                                ...

	)); ?>

	<?php echo CHtml::submitButton('Show'); ?>

<?php echo CHtml::endForm(); ?>


<?php 

if($_POST)

{

	$this->widget('zii.widgets.grid.CGridView', array(

		'id'=>'table-grid',

		'ajaxUpdate'=>false,

		'dataProvider'=>new CArrayDataProvider($model, array()),

		'columns'=>array(

			'id',

                        ...

		),

	)); 

}	

?>



Thank you very much. :)