Environment:Amazon EC2. Ubuntu x64. (GD library installed)
I'm recently using phpChart for graph and report in laravel framework.
I'm stuck at the beginning stage.
Here's what I've done.
1.Unzip the contents in phpChart_Lite to /var/www/app/libraries/phpChart.
2.Edit composer.json and add :
"autoload": {
"classmap": [
...
"app/libraries"
]
},
3.run:composer dump-autoload
4.modify conf.php in phpChart_Lite
define('SCRIPTPATH',app_path().'/libraries/phpChart_Lite/');
Here's my test page code:
<?php
require_once(app_path()."/libraries/phpChart_Lite/conf.php");
$pc = new C_PhpChartX(array(array(11, 9, 5, 12, 14)),'basic_chart');
$pc->draw();
?>
ps.my app_path() is verified by "echo app_path()" and it is "/var/www/app".
Here's my error message:
Unknown: Failed opening required '/var/www/public//var/www/app/libraries/phpChart_Lite//conf.php'
(include_path='/var/www/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/php:/usr/share/pear')
After a lot of try-and-error, I somehow found the root cause, I guess.
There are actually two main issue there. And here's my solution.
1.For my issue explained in the very first post.
In the conf.php file in phpChart_Lite folder. The SCRIPTPATH is somehow prefixed with /var/www/public.
However, in my apache2.conf file states the directory to be /var/www. Regardless this prefix, I use a absolute path for SCRIPTPATH. The following modification works for me:
define('SCRIPTPATH','../app/libraries/phpChart_Lite/');
The error was gone. But the second issue appears, that is the chart doesn't show up.
Open the Chrome Developer Tool(press F12). On the 'Console' tab, I found error 404 for loading phpChar_Lite/js. One of the error messages as following:
http://myip/app/libraries/phpChart_Lite/js/highlighter/styles/zenburn.css
As the design of Laravel, only public folder can be access by external request.
So I got second issue. And here's my solution.(not a secured method)
2.Move the phpChart_Lite to public folder. Modify the code of test page:
include_once(public_path()."/phpChart_Lite/conf.php");
Modify the conf.php in public/phpChart_Lite:
define('SCRIPTPATH','phpChart_Lite/');
Everything's just fine now.
If you consider phpChart is too complicate to configure with, you might want to try pChart2.0.
It doesn't require much setting. But the graph is terribly ugly.
I prefer phpChart for it's graph and function calls, though the setting is a little complicated and not laravel friendly.
Related
I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.
Recently, I installed lumen (5.0.4) mfw and ran into an issue with page load on default configuration. I have unpredictable behavior of page load process.
Sometimes it loads okay but sometimes instead of loading I am getting a download dialog with zero size unnamed file or it throws an exception like
NotFoundHttpException in Application.php line 1109:
(At first, I want to say that other non lumen/laravel sites work fine) Server configuration:
Apache 2.4.12
PHP 5.6.7-1
Zend Engine v2.6.0 with Zend OPcache v7.0.4-dev
I think the problem is with php working through php-fpm because with fcgi configuration it seems to work well.
I tried NotFoundHttpException with Lumen but that didn't help me.
I have same issue, after hours of research and debug, I fixed the issue.
If you are doing something like this ...
$app->run($httpRequest);
instead do ...
$httpRequest = Illuminate\Http\Request::capture();
$app->run($httpRequest);
Hope this is helpful. Thanks!
Change $app->run(); to $app->run($app['request']); in public/index.php (Lumen 5.2)
So I installed Phalcon and the phalcon devtools. When I try anything, it throws an error (Generate model, generate controller and scaffolding). Looked around and I can see other people had this problem but I cannot find a solution.
Generate Model page:
Error on generate:
webtools.config.php:
define('PTOOLS_IP', '192.168.0.81');
define('PTOOLSPATH', 'C:/phalcon-tools/vendor/phalcon/devtools');
Error on generate controller:
Please specify a controller directory
Error on generate model:
Database configuration cannot be loaded from your config file
Error on scaffolding:
Adapter was not found in the config. Please specify a config variable [database][adapter]
Had this same issue the other day. I found a work around but it's far from ideal.
Find
\devtools\scripts\Phalcon\Builder\
And open Components.php
Inside this file find the line:
foreach (array('/app/config/', 'config/') as $configPath) {
This line needs to be either:
(array('/../app/config/' <- For model Generator to work.
or
(array('../app/config/' <- For scaffolding Generator to work.
I can't for the life of me work why, and it's far from ideal trying to remember to do it every time you need to use the tools, but it works.
I've developed a small project on a machine, using CakePHP 3.0, and I need it to run on another machine. I've tried to install it on several other machines.
If I run the composer to install the CakePHP 3.0, then I copy my stuff to overwrite it, the project works. I've tried this on two machines and had no problem so far. If I don't run the composer, and just copy the stuff to the target machine, it gives me the following error. I've tried this on 3 machines, and every machine gives me this:
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
I've copied the whole project to this server to test.
I told you this because I thought it has something to do with my problem. The point is that I have to run this on a machine that is not mine, and I can't install composer on it. The /public_html/vendor/cakephp/cakephp/src/I18n/ has files related to internationalization and localization, but my project will never be translated, so a workaround to make the project ignore those files would be enough to solve my problem.
The following code is an excerpt from the (...)/I18n/I18n.php that might be relevant:
<?php
namespace Cake\I18n;
use Aura\Intl\FormatterLocator;
use Aura\Intl\PackageLocator;
use Aura\Intl\TranslatorFactory;
use Cake\I18n\Formatter\IcuFormatter;
use Cake\I18n\Formatter\SprintfFormatter;
use Locale;
class I18n {
// lots of code here
public static function defaultLocale() {
if (static::$_defaultLocale === null) {
static::$_defaultLocale = Locale::getDefault() ?: 'en_US';
// the line above is the Line 229
}
return static::$_defaultLocale;
}
// many code here too
}
I've checked that another file also tries to access this Locale class, but I don't know if there are other files trying to access it as well. Many files from everywhere inside the project tries to access methods from I18n.php. I need it running but I can't figure out how to make it run.
Any help will be greatly appreciated.
As I just found out, prior to CakePHP 3.0, the installation must be done by composer, as stated in the 3.0 migration guide:
CakePHP should be installed with Composer
Since CakePHP can no longer easily be installed via PEAR, or in a shared
directory, those options are no longer supported. Instead you should use
Composer to install CakePHP into your application.
So it won't run on regular free web hosting services.
I'm working in a symfony-based project. I did not do.
The page works in a simple webserver (debian+apache+php) and i move this from my home server, with Debian + Nginx + php-fpm, this works, but it throws an error that did not.
The complete error is here: http://pastebin.com/PCy0v1J6
Have you moved all your files? I guess that Brick is an object in your schema.yml, and it has a property 'title'. You should have a file BaseBrickForm.class.php in lib/form/doctrine/base, if you don't you should execute ./symfony doctrine:build --all-classes. It's common to have the autogenrated classes ignored by a versioning system, so it may be the source of your problem.
In SF_ROOT_DIR/lib/form/brickForm.class.php line 23ff you have :
$this->useFields(array('title', 'content'));
Please check the widgets defined in your BaseBrickForm.class.php file and if brickForm.class.php is extending BaseBrickForm !