How to Integrate Jasper Reports in Codeigniter PHP - codeigniter

I have tried below link to integrate jasper report in Codeigniter php
but it doesn't works
http://community.jaspersoft.com/questions/822686/how-connect-jasper-reports-php-application
Can anybody explain any other method to integrate jasper reports in Codeigniter PHP ?
EDIT
Code:
<?php
require_once APPPATH . "report/vendor/autoload.dist.php";
header('Content-Type: text/html');
use Jaspersoft\Client\Client;
$c = new Client( "localhost", "8080", "jasperadmin", "jasperadmin", "/jasperserver-pro", "organization_1" );
$report = $c->reportService()->runReport(APPPATH.'/report/sample_repor‌​t', 'html');
echo $report;
?>

When you want to use Jaspersoft Reports, you cannot use pre-created PDF files.
The process looks more or less like this:
Take Jaspersoft Studio to design report (will give jrxml file)
Upload jrxml file somewhere
Use some kind of PHP wrapper to create a report when you need it with fresh data, like the Jaspersoft PHP Rest Client. For more explanation see this question
Then this report can be created for example as a PDF file and provided for downloading
If you already created and filled the PDF files, it is more or less a question how to provide the PHP download.

Related

unable to generate PDF from spatie bowsershot

i have installed browsershot in my laravel project
I have installed puppeteer, installed chromium , my npm version is updated, but still i am unable to get the PDF of my simple html input , i have tried to take screenshot by URL method and save as image(It works), but my requirement is to generate PDF of my html.
This is my code in controller
$output=Browsershot::html($html)
->setNodeModulePath("/var/www/html/ProjectName/node_modules/")
->setChromePath("/usr/bin/chromium-browser")
->setNodeBinary('/usr/local/bin/node')
->setNpmBinary('/usr/local/bin/npm')
->showBackground()
->noSandbox()->timeout(60)
->save(public_path("DevTest.pdf");
Error Message:
"message": "The process "PATH=$PATH:/usr/local/bin NODE_PATH='/var/www/html/ProjectName/node_modules/' /usr/local/bin/node '/var/www/html/benesprint/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/1933874416-0068512001600765779\/index.html","action":"pdf","options":{"path":"\/var\/www\/html\/ProjectName\/public\/DevTest.pdf","args":["--no-sandbox"],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"executablePath":"\/usr\/bin\/chromium-browser","timeout":60000,"printBackground":true}}'" exceeded the timeout of 60 seconds.",
**i would be grateful if you can help me out.**
i have similiar problem when browsershot inside container. and my step to resolve is like this:
Manual generate PDF from html using laravel tinker. if there is an error, try reinstall chromium and puppeteer library.
If success, then try remove all css and javascript links from html, and check for the result.
If success, then add --proxy-server="direct://" and --proxy-bypass-list=* into browsershot args
If step 3 is not working, then you can put css and javascript directly into view template or using php code to inclue those files like
<?php include public_path('css/styles.css') ?>

OctoberCMS and BotMan

I want to integrate a chatbot (BotMan version 2.0) into an existing OctoberCMS project , here is what I did till now :
1- I added BotMan to the projct using the following command :
composer require botman/botman
2- I created a routes.php file in the same directory as the plugin.php file
<?php
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
//Route::match(['get', 'post'], '/botman', 'BotManController#handle');
//Route::get('/botman/tinker', 'October\Demo\BotManController#tinker');
// Create an instance
$botman = BotManFactory::create($config);
// Give the bot something to listen for.
$botman->hears('hello', function (BotMan $bot) {
$bot->reply('Hello yourself.');
});
// Start listening
$botman->listen();
My questions are :
1- Where I have to add the BotManController.php file
2- I tried to add BotManController.php in the same directory as the routes.php file but I get the following error :
Class 'App\Http\Controllers\Controller' not found
( and thats because its an OctoberCMS project not Laravel project ... I dont have the App directory )
Can anyone please provide me a solution to that or another way to integrate Botman into OctoberCMS !
First off, read https://luketowers.ca/blog/how-to-use-laravel-packages-in-october-cms-plugins/ as well as https://octobercms.com/docs/plugin/composer.
Secondly, you can put the BotManController file anywhere in your plugin you want as long as you understand PHP namespaces and how to properly reference it where you want to. I would probably recommend putting it in a /classes/ directory under your plugin folder, and then changing the App\Http\Controllers\Controller reference to instead reference the base Illuminate\Routing\Controller class. You could also put it in a /controllers/ directory, but in OctoberCMS that is typically reserved for your backend controllers so I wouldn't recommend mixing the two.

Any wordpress plugin image captcha with shortcode

I am trying to use a Image Captcha plugin on my website.
Currently I am using google reCaptcha plugin with V2.
But I need a captcha with Image (like Flexible Captcha), I tried using it, but Image dosen't load for this plugin.
I searched for many, but I want it with short code, so that I can place it on my custom forms.
Or If anyone knows how to remove image issue with "Flexible Captcha" plugin, please post your solution.
Edit:
I also tried to use the Securimage-WP plugin as suggested by drew010. Following is the output of plugin:
On Admin settings for plugin:
On Login page:
Note:
My website URL is like http:abc.com/myWebFolder/
Is this thing breaks the plugin to work or it could be the theme issue.
Thanks
My plugin Securimage-WP offers a shortcode for putting a captcha on a custom form.
The plugin also defines a function which you can then call to validate the submitted CAPTCHA.
I have posted a gist here which shows a WordPress page that uses the shortcode on a form and then validates the form and CAPTCHA. Note: Since this page uses PHP, you will need a plugin (I use Exec-PHP) that allows you to run PHP code in posts and pages.
If you need to validate the CAPTCHA in a form processor that is independent of WordPress, you can hook into WP and the plugin by including wp-load.php from the root of your WordPress install.
Comment if you have any questions. Hope this helps!
thank you drew010 for your help, I made complete new installation of wordpress & used your plugin & it worked, then I also used Flexible Captcha plugin & that also worked. Then in order to debug the real problem I add my custom plugin code in new Wordpress. Then it braked. Therefore, to debug more I added each method in my plugin & tested it worked with method. The culprit was following code:
/**/
?>
<?php
function displayLoginForm() {
/*
ob_start();
get_template_part( 'signin-form' );
$ret = ob_get_contents();
ob_end_clean();
return $ret; */
ob_start();
include(ABSPATH . "wp-content/plugins/tus-forms/Views/sign-in.php");
$output = signin_get_clean();
return $output;
}
?>
Changing above into following solved my problem:
function displayLoginForm() {
/*
ob_start();
get_template_part( 'signin-form' );
$ret = ob_get_contents();
ob_end_clean();
return $ret; */
ob_start();
include(ABSPATH . "wp-content/plugins/tus-forms/Views/sign-in.php");
$output = signin_get_clean();
return $output;
}
?>
But I still don't know the real reason behind this issue?
but finally it worked.
Thanks
Captcha On Login This plugin is more flexible with image and its having another feature include of blocking ip and removing ip from blocked. I am using this plugin it is really good.
enter image description here

image display in codeigniter shows error

I am relatively new to Codeigniter, basically I choose CakePHP to develope applications. Now I am editing a Codeigniter Project, build in version 2. I have some images in my table and I need to disply it.
I have created a helper file general_helper.php in which I have a function
function image_url(){
return base_url().'uploads/';
}
So in view page , I tried to display image by
<img src="http://localhost/myapp/uploads/vendors/images/Desert.jpg" />
My directory structure is :
myapp
-uploads
-vendors
-images
-logos
But its not showing the image ! When I tried to put the image path in the url, it shows 404 error :( whats wrong ?
Codeigniter base_url function requires folder path relative to site's base url passed as parameters. Please try use below code.
First in constructor, please load your library -
$this->load->library('general');
Then please pass your uploads directory as parameter to base_url
function image_url(){
return base_url('uploads/');
}
If images are not uploading please do check image type.
Also try use log_message('info','info_message') function to record base url.
Please refer http://www.codeigniter.com/userguide2/general/errors.html

smarty not working in codeigniter

I installed Smarty in Codeigniter and it's not really working. Here is what I did:
I followed this instructions:
http://sunwebexpert.com/books/detail/PHP/integrating-smarty-and-codeigniter.html
But I also put another file in the library: parser.php which is a library to do parsing (I've used it before with smarty and worked well)
the on Codeigniter's autoload.php wrote this:
$autoload['libraries'] = array('parser','smarty');
On main controller I wrote this function to test:
public function index()
{
$this->data['d'] = 2;
$this->parser->parse('base/test.tpl', $this->data);
}
but the result is no error display and I see the variable 'd' as it is wrote in the template:
{$d}
So I have two questions:
Why can't I see the variable value if I installed smarty as I did before in other projects?
How can I enable to see errors if there are?
The problem is that in codeigniter, there is a built-in library called Parser. That's why this may cause conflict with your library name. Try to rename your library name or use built-in library.
Here is how to display error on codeigniter.
Hope it will be useful for you.

Resources