The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

joew (4) [Avatar] Offline
#1
Hi,

yesterday I downloaded the latest version of chapter 16 - 17 application. In the apache root dir ( /var/www/html/) I created the directory 'extJSinaction' in which I unpacked the downloaded zip. After importing the mysql dump I edited the database.php for correct database access credentials. Trying this URL: http://myserver/extJSinaction/index.php I get the login popup. After successful login the application is shown without any data from the database. Apache log says: File does not exist: /var/www/html/extJSinaction/stats
I get the same error for other files too. So I think it is a path problem. What did I forget to adapt in my config?

Thanks for answer

Joe
jesus.garcia (463) [Avatar] Offline
#2
Re: Chapter 16 - 17 application doesn't work
Hi Joe,

Do you have an .htaccess file in your extjsinaction dir?
joew (4) [Avatar] Offline
#3
Re: Chapter 16 - 17 application doesn't work
of course
jesus.garcia (463) [Avatar] Offline
#4
Re: Chapter 16 - 17 application doesn't work
Do you have a named virtual host mapped?

For instance,

I access the app via: http://extjsinaction/


my httpd.conf has:

<VirtualHost *:80>
ServerAdmin liquid@localhost
DocumentRoot /www/extjsinaction
ServerName extjsinaction
ServerAlias extjsinaction
ErrorLog /tmp/extjsinaction.httpd.errlog
<Directory /www/extjsinaction>
AllowOverride All
Options ExecCGI FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
joew (4) [Avatar] Offline
#5
Re: Chapter 16 - 17 application doesn't work
Hi Jesus,

thanks for help. Now the path problem is solved. but there are not yet data in the application. In error log I found: PHP Fatal error: Call to undefined function json_encode() in /var/www/html/extjsinaction/ci/application/controllers/departments.php on line 29

Can you help me ??


Joe
jesus.garcia (463) [Avatar] Offline
#6
Re: Chapter 16 - 17 application doesn't work
json_encode is a php5 function smilie
joew (4) [Avatar] Offline
#7
Re: Chapter 16 - 17 application doesn't work
Hi Jesus,

PHP Version 5.1.6 is installed on my server.

Joe
jesus.garcia (463) [Avatar] Offline
#8
Re: Chapter 16 - 17 application doesn't work
that's very strange.


json_encode is a built in PHP function:



<? <br /> $a = array('someKey' => 'some value');
echo json_encode($a);
echo "
";


(OUTPUT BELOW)
{"someKey":"some value"}


http://php.net/manual/en/function.json-encode.php
AliceDD (1) [Avatar] Offline
#9
Re: Chapter 16 - 17 application doesn't work
Hey mate,

the problem is in you php version, if you haven't done it so far. Please refer to this page - 'http://www.sencha.com/learn/Tutorial:Ext_StartUp_Guide', the section 'php' explains what shall be done.

Hope that helps,
Alice
xo0ox (3) [Avatar] Offline
#10
Re: Chapter 16 - 17 application doesn't work
A view hints for those running into the first problem, of data not being loaded.

As JG already pointed out, this might be due to the URL rewrite rule in the .htaccess file not being active. This can be easily verified by calling the 'service' directly and including the 'index.php' part:

http://servername/index.php/departments/getList

If this works, the culprit is the rewrite rule not being active/enabled. The app references the 'services' without the 'index.php'...

http://servername/departments/getList

which requires the apache url rewrite rule.

Check if the .htaccess file is present in the application's root folder.

In my case, I had to modify the apache2 config file to allow overriding the rewrite rule

AllowOverride All

and, furthermore, enable the apache rewrite module on my rather 'fresh' Ubuntu server install, which shows up in the apache error logs as 'RewriteEngine invalid command'

sudo a2enmod rewrite


For me, it still didn't work out yet. I had installed the app to a sub-directory of a virtual host, and the rewrite rule gave me troubles...

404 /index.php/departments/getList not found

I had to fix the rewrite url to exclude the leading slash

RewriteRule ^(.*)$ index.php/$1 [L]


Hope that will help others!
brushback (1) [Avatar] Offline
#11
Re: Chapter 16 - 17 application doesn't work
In addition to the VirtualHost and .htaccess issues well described in the above posts, I encountered problems stemming from short open php tags, which were used in several of the applications php files. Short open tags are "<?" rather than "<?php" in your php script. I found them included in the userlogin.php and userlogout.php files, as well as several of the application/controllers and application/model classes. <br /> <br /> If the "short_open_tags" directive in your php.ini is disabled, none of the affected classes will work, and the server will not be able to serve JSON to the client. <br /> <br /> This strikes me as a bug that's very much worth fixing in the source code. <br /> <br /> Here's a good overview of the debate on short tags... <br /> http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use
jesus.garcia (463) [Avatar] Offline
#12
Re: Chapter 16 - 17 application doesn't work
@brushback,

You have a great point. I'll work to fix this as soon as I can and will report with an updated link to the downloadable zip.
Jetbar (2) [Avatar] Offline
#13
Re: Chapter 16 - 17 application doesn't work
i want to share.
now, i have solve my problem. Now it's work on my win xp, using xampp.

i have change content of .htaccess, to be like here:
RewriteEngine on
# exclode these
RewriteCond $1 !^(index.php|userlogin.php|userlogout.php|user_guide|docs|resources|images|ext3|robots.txt)
RewriteRule ^(.*)$ http://localhost/extjsinaction//index.php/$1 [L]


and change config.php( Csmilieampphtdocsextjsinactionciapplicationconfigconfig.php )
$config['base_url'] = "http://localhost/extjsinaction/";

and import the database to mysql, and change the database.php.

now, all works for me.

tks,