Laravel: Helpers class not found on live site. Works locally - php

I am attempting to use the thujohn/twitter package to get a live twitter feed on my site.
I got it working on my local server by using the tutorial found here but when I uploaded the changes to my digital Ocean server, I got the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Helpers' not found
Here are the steps I took - not much code:
I downloaded the package with artisan
config/app.php: added 'Thujohn\Twitter\TwitterServiceProvider', to the providers and 'Twitter' => 'Thujohn\Twitter\TwitterFacade' to the aliases
added app_path().'/classes', to the start/global.php file
I added a Helpers class to classes/helpers.php, which contains:
public static function twitterFeed($screen_name='screenName', $count='1', $include_retweets='false', $exclude_replies='true')
{
$twitterfeed = Cache::remember('twitterfeed', 30, function() use ($screen_name, $count, $include_retweets, $exclude_replies) {
return Twitter::getUserTimeline(
array(
'screen_name' => $screen_name,
'count' => $count,
'include_rts' => $include_retweets,
'exclude_replies' => $exclude_replies
)
);
})
;
if(!empty($twitterfeed)) {
return $twitterfeed;
}
else {
return array();
}
}
Put a view::share in my route file:
View::share('tweets', Helpers::twitterFeed('contractrsherpa', '1', false, true));
then looped through it in my view.
Finally, ran composer dump-autoload.
Seems pretty straightforward and works great locally. I uploaded everything to my liver server, ran composer dump-autoload, but still get the error "class 'Helpers' not found."
Any idea what I need to do to get this to work on the live site?
TIA

Related

Laravel AWS S3 Adapter class not found

I'm trying to upload files to Amazon s3 using Laravel 5.8, it actually works on locally but I am unable to get it to work online. I got error:
Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found
I've run 'composer dump-autoload', 'composer install'commands I've even tried to upload vendor folder. The .env file is the same locally and online so I'm pretty sure that is not a credentials problem.
This is my post code:
public function postUpload(StoreImage $request)
{
$path = Storage::disk('s3')->put('images/registry', $request->file, 'public');
$request->merge([
'size' => $request->file->getClientSize(),
'path' => $path,
'auth_by' => $request->patient
]);
$this->image->create($request->only('path', 'title', 'size', 'auth_by'));
return back()->with('success', 'Image Successfully Saved');
}
So I'm getting this error:
Please any help would be great :).
You should install AWS adapter package
composer require league/flysystem-aws-s3-v3

Error loading cakephp 2 plugin

I installed a plugin in CakePHP from Upload, I loaded it into in app / Config / bootstrap.php. thus
CakePlugin::load('Upload'); but I'm getting the error below, do I need to do anything else? CakePHP 2.0
Error: Upload.UploadBehavior could not be found.
Error: Create the class UploadBehavior below in file: C: \ xampp \
htdocs \
This class already exists in the plugin!
From the Upload Plugin Github Page:
This plugin work as a behaviour for your model so you have to attach it to your model
public $actsAs = array(
'Upload.Upload' => array(
'fields' => array(
'thumb' => 'img/posts/:id1000/:id'
)
)
);

Install OmniPay without Composer

I don't want to use composer to install Omnipay but rather use traditional PHP includes to setup Omnipay with Stripe.
How do i do this? I have extracted it to this folder:
www.mysite.com/payments/src
Stripe.php with example code is here:
www.mysite.com/payments/Stripe.php
Where do i put the stripe payment gateway files?
What PHP files do i need to include in the header example code?
I am using this example code:
include $_SERVER['DOCUMENT_ROOT']."/payments/src/Omnipay/Omnipay.php";
use Omnipay\Omnipay;
$gateway = Omnipay::create('Stripe');
$gateway->setApiKey('abc123');
$formData = ['number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response);
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
Not sure why you want to go that way, but if you really want to why not just install it with composer in another location and then copy the files (including the composer autoload file) in your project.
I'm running xampp on Windows and initially I didn't want to use composer either but once composer is installed then all I needed to do was to create the composer.json file in the project directory with the code below and in cmd change path to the project directory and type composer install.
{
"require": {
"omnipay/stripe": "~2.0"
}
}
I could then see why a manual installation is not documented because it automatically installed the all the following dependancies and configured the autoload files vendor/composer/:
vendor/autoload.php
vendor/composer
vendor/guzzle
vendor/omnipay/common
vendor/omnipay/stripe
vendor/symfony/event-dispatcher
vendor/symfony/http-foundation
vendor/symfony/polyfill-mbstring
composer.lock

omnipay pin payments with cake php 2.0

I need help regarding omnipay pin payments. i have no clue how to integrate this to cake php.
i tried this sample code but dint get success
$gateway = GatewayFactory::create('Pin');
$gateway->setSecretKey('your-secret-api-key');
$gateway->purchase([
'email' => 'customer#email.com',
'description' => 'Widgets',
'amount' => '4999',
'currency' => 'USD',
'card_token' => 'card_nytGw7koRg23EEp9NTmz9w',
'ip_address' => '1.2.3.4'
])->send();
Fatal error: Class 'GatewayFactory'
Please help me . Thanks in advance
You need to use Composer to install Omnipay. This is explained in the Omnipay Readme.
Make a file called composer.json in the root of your project directory:
{
"require": {
"omnipay/pin": "~2.0"
}
}
Then run the following commands in a terminal window:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
This will download the Omnipay files into your vendor/ directory.
Next, you will need to put the following line at the top of your index.php file, to register the composer autoloader:
require 'vendor/autoload.php';
Finally, you can use Omnipay in your project to create the Pin gateway:
$gateway = Omnipay\Omnipay::create('Stripe');

Symfony 2 'The process has been signaled with signal 5' while using wkhtmltopdf with knpsnappy

Help me out here....
I have installed wkhtml2pdf 0.9.9 static for mac os and installed it in the /usr/bin. Wkhtml2pdf works fine from the terminal, with the wkhtmltopdf [source website][generated file to be saved].
Though I am unable to use it in Symfony 2.3.7, with the knpSnappy and knpSnappyBundle installed. I am sure I have entered everything correctly. I have checked it a million times and searched all of the google and yet couldnt find why it would do that (been searching for two days.
I have downloaded knpSnappy and knpSnappyBundle through composer and it is in the vendor and as well as enabled in the config.yml and added to appkernel.php, other than that Following is my configuration:
Composer:
"knplabs/knp-snappy-bundle": "dev-master",
"knplabs/knp-snappy": "*"
Appkernel:
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
Controller:
public function generateAction($date)
{
$em = $this->getDoctrine()->getManager();
$publishedAds = $em->getRepository('pdfRenderAdBundle:Ads')
->getAllAds();
if (!$publishedAds) {
throw $this->createNotFoundException(
'No ads found for today!'
);
}
$html = $this->renderView('pdfRenderAdBundle:Application:generate.html.twig', array(
'publishedAds' => $publishedAds
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
400,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
}
SYMFONY VER: 2.3.7
WKHTMLTOPDF: 0.9.9 STATIC OSX KNPSNAPPY LIB &
KNPSNAPPY BUNDLE: THE LATEST ONE THROUGH SYMFONY
Whenever I try to access the controller it gives the:
The process has been signaled with signal "5" - 500 Internal Server Error - RuntimeException
I will really appreciate it if any one of you can help out of this well..... Stuck here for a very long time now.
For anyone else that comes across this, here's the post on how to get this working:
http://oneqonea.blogspot.com/2012/04/why-does-wkhtmltopdf-work-via-terminal.html
Here's the short version:
Comment out the following line in /Applications/MAMP/Library/bin/envvars
#export DYLD_LIBRARY_PATH
And then add this line:
export PATH=/parent/path/of/wkhtmltopdf/executable:$PATH
I had this problem as well, and if IIRC the solution was to use wkhtmltopdf version 0.9.6.

Categories