Laravel 5.2.45 Tcpdf installation failed with php version 5.5.11 - laravel-5

I need to generate a PDF using TDPDF with Laravel 5.2.45.
I used the following command (reference: here):
composer require elibyy/tcpdf-laravel
and received the following message:
Message: Your PHP version <5.5.11> does not satisfy that requirement.
Is there any other way to download TCPDF with Laravel if my PHP version do not satisfy the requirement?

I updated my composer with following command
composer update
Then added the following line to my composer.json file
{
"require": {
"elibyy/tcpdf-laravel": "5.4.*"
} }
Next added the service provider to config/app.php.
'providers' => [
//...
Elibyy\TCPDF\ServiceProvider::class,
]
//...
'aliases' => [
//...
'PDF' => Elibyy\TCPDF\Facades\TCPDF::class
]
and again run the following command
composer update
And then to my controller I added the following lines:
use PDF; // at the top of the file
PDF::SetTitle('Hello World');
PDF::AddPage();
PDF::Write(0, 'Hello World');
PDF::Output('hello_world.pdf');
Now I am able to generate a PDF.

Related

Can not get access to Telescope dashboard

I want to add telescope into my laravel 8 app, but having in .env
APP_ENV=local
TELESCOPE_ENABLED=true
and reading at site :
https://laravel.com/docs/8.x/telescope
The Telescope dashboard may be accessed at the /telescope route. By default, you will only be able to access this dashboard in the local environment.
on url
http://local-tads.com/telescope
I got 404 error, where http://local-tads.com - is local hosting of my app
In app/Providers/AppServiceProvider.php file I added lines :
<?php
namespace App\Providers;
class AppServiceProvider extends ServiceProvider
...
if ($this->app->environment('local')) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
\Event::listen(
[
TransactionBeginning::class,
],
function ($event) {
...
I have unmodified vendor/laravel/telescope/config/telescope.php file.
Have I to add route in routes/web.php and in which way ?
How to get access to telescope dashboard ?
UPDATED BLOCK :
I run both commands :
php artisan telescope:install
php artisan migrate
But I did not find config/telescope.php, so I copied it from /vendor/ subdirectory
Running command
php artisan route:list
has no any “telescope” entry.
In file app/Providers/AppServiceProvider.php I added lines with telescope :
<?php
namespace App\Providers;
use App\Library\Services\AdminCategoryCrud;
//use App\Providers\TelescopeServiceProvider;
use Illuminate\Database\Events\TransactionBeginning;
use Illuminate\Database\Events\TransactionCommitted;
use Illuminate\Database\Events\TransactionRolledBack;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
if ($this->app->environment('local')) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
}
Not sure if all is correct?
in env I have :
APP_ENV=local
TELESCOPE_ENABLED=true
and in composer.json I added line :
"extra": {
"laravel": {
"dont-discover": [
"laravel/telescope"
]
}
},
and updated composer
But http://local-tads.com/telescope - still raise 404 error...
Thanks in advance!
I have this problem but I attention Laravel Documentation I watch this code and run them:
telescope:install
, you should remove the
TelescopeServiceProvider
service provider registration from your application's
config/app.php
configuration file. Instead, manually register Telescope's service providers in the
register
method of your
App\Providers\AppServiceProvider
class.
A potential answer to your problem could be removing the telescope package from the dont-discover array. So your new extra section would be like this one:
"extra": {
"laravel": {
"dont-discover": []
}
}
Also, don't forget to dump your autoload by running composer dump-autoload in your project folder. I hope this helps you :D
For more information please check this issue on the github repository.

Laravel and php wrapper for youtube-dl norkunas / youtube-dl-php

I'm using Laravel Version 6.14.0 and I wanted to use the following Youtube-dl wrapper for PHP from https://github.com/norkunas/youtube-dl-php in Laravel.
I used the command composer require norkunas/youtube-dl-php to install it and I got the following output :
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
- Installing symfony/options-resolver (v4.4.4): Downloading (100%)
- Installing norkunas/youtube-dl-php (v1.4.0): Downloading (100%)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
This is what my Controller looks like
<?php
namespace App\Http\Controllers;
use App\YtScreen;
use Illuminate\Http\Request;
use YoutubeDl\YoutubeDl;
use YoutubeDl\Exception\CopyrightException;
use YoutubeDl\Exception\NotFoundException;
use YoutubeDl\Exception\PrivateVideoException;
class YtScreenController extends Controller
{
public function frontpage()
{
$dl = new YoutubeDl([
'continue' => true, // force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.
'format' => 'bestvideo',
]);
// For more options go to https://github.com/rg3/youtube-dl#user-content-options
$dl->setDownloadPath('/home/user/downloads');
// Enable debugging
$dl->debug(function ($type, $buffer) {
if (\Symfony\Component\Process\Process::ERR === $type) {
echo 'ERR > ' . $buffer;
} else {
echo 'OUT > ' . $buffer;
}
});
try {
$video = $dl->download('https://www.youtube.com/watch?v=oDAw7vW7H0c');
echo $video->getTitle(); // Will return Phonebloks
// $video->getFile(); // \SplFileInfo instance of downloaded file
} catch (NotFoundException $e) {
// Video not found
} catch (PrivateVideoException $e) {
// Video is private
} catch (CopyrightException $e) {
// The YouTube account associated with this video has been terminated due to multiple third-party notifications of copyright infringement
} catch (\Exception $e) {
// Failed to download
}
return view("frontpage");
}
}
The problem is that the newly installed php wrapper doesn't work at all. I don't even get an error message. No video gets downloaded, no error message is shown ... nothing happens. The controller itself is fine , I tested it with a different function.
I assume I didn't include the files correctly since I don't even get an error message. Has anyone made a similiar expirience and knows how to get this php wrapper for youtube-dl to work in Laravel? Or maybe has an alternative idea for a different youtube-dl php wrapper.

Laravel php artisan produces error

I have integrated and working in a Laravel 5.4 project. I was actually configure this correctly and php artisan command was working perfectly before.But in between the development time(I have implemented the schedule task using laravel and not sure after that issue appear) it produces m error on php artisan commands. Can anybody help me on this.
The following is the error log for the command for any artisan command
PHP Fatal error: Uncaught
Symfony\Component\Debug\Exception\FatalThrowableError: Type error:
Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct()
must be an instance of Illuminate\Http\Request, null given, called in
/var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php
on line 60 in
/var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:103
Stack trace:
#0 /var/www/html/projrct/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(60):
Illuminate\Routing\UrlGenerator->__construct(Object(Illuminate\Routing\RouteCollection),
NULL)
#1 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(290):
Illuminate\Routing\RoutingServiceProvider->Illuminate\Routing{closure}(Object(Illuminate\Foundation\Application))
#2 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(746):
Illuminate\Container\Container->Illuminate\Container{closur in
/var/www/html/project/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php
on line 103
Please make sure that you are not using any url() or asset() or other helpers functions inside your configuration files
I my case url() helper function in my filesystem.php is causing the issue. I removed it and every thing works fine.
Another alternative solution to commenting out the url() and asset() calls could be to check the environment at run time:
return [
'URL' => app()->runningInConsole() ? '' : url(''),
...
];
If Really Need The Function To Be Inside Your Config, You Could use PHP_SAPI
To Check Weather The App Is Running HTTP or CLI,
'redirect' => PHP_SAPI === 'cli' ? false : url('synchronise')
I figured out the problem, when you are running any artisan command you should avoid using helper functions in any of your config files. Just comment those and try to run artisan command after running that uncomment your config files.
//in config/'any_file.php'
return [
'name' => 'Larvel',
'url' => url('/')
];
//just change and uncomment url() helper
return [
'name' => 'Larvel',
//'url' => url('/')
];
Well I got stuck at same issue while I was using asset in config file (adminlte.php) of Admin LTE.
Please comment your asset, url while using artisan command in config files like this
[
'type' => 'js',
'asset' => false,
// 'location' => asset('js/waitme/waitMe.min.js'),
],

How to tell Laravel 5 to aoutoload my custom package?

I have create in vendor directory the following structure for my package:
/vendor/
koala/
bamboo-sdk/
src/
Engine2/
Utils/
I then run
$composer init
inside koala folder.
Lately I went to Laravel5 composer.json main. And modified the autoload.psr-4 part like this:
"autoload": {
"classmap": [
"database"
],
"psr-4": {
...
"Koala\\BambooSdk\\": "vendor/koala/bamboo-sdk/src"
}
},
I then run
$composer dump-autoload
in order to have /vendor/composer/autoload_classmap.php updated with the new references.
But I dont see it changing.
Also having a new controller with directive:
use Koala\BambooSdk\MyClass;
and then below
$myobj = new MyClass();
will result in a error:
FatalErrorException in MyController.php line 165:
Class 'Koala\BambooSdk\MyClass' not found

cakephp 3.0 recaptcha installation

I try to use recaptcha with cakePHP 3.0, but I experience some errors probably dues to a wrong installation.
I work on Windows with composer.
I've add the following lines to composer.json file :
"require": {
(...)
"google/recaptcha": "~1.1"
},
"autoload": {
"psr-4": {
(...)
"ReCaptcha\\": "/vendor/google/recaptcha/src/ReCaptcha"
}
},
Then I execute composer cmd to install the plugin:
composer update
composer install
composer dumpautoload
Finally, I test the plugin in a view :
<?php
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// verified!
} else {
$errors = $resp->getErrorCodes();
}
?>
The result is an error throwed by cake :
"No secret provided (...) Could this be caused by using Auto-Tables? ..."
Did I correctly installed it ?
Did I miss or misunderstand something ?

Resources