I want to use the https://github.com/vstelmakh/url-highlight plugin on Github. I'm doing everything right, I created the files on localhost. But while the same codes work correctly on localhost, it gives the following error on the online server.
PHP Fatal error: Uncaught Error: Class
'VStelmakh\UrlHighlight\UrlHighlight' not found in
/home1/****/public_html/includes/connect.php:4
<?php
require __DIR__ . '/vendor/autoload.php';
use VStelmakh\UrlHighlight\UrlHighlight;
$urlHighlight = new UrlHighlight();
echo $urlHighlight->highlightUrls('Hello, http://example.com.');
The same codes work fine on localhost. But if it does not work on the online server, what could be the reason for this.
Related
I have a Laravel 5.3 project in which I inherited a piece of code that sends out an email:
use Illuminate\Support\Facades\Mail;
$mail = Mail::to($user->email);
$result = $mail->returnPath('test#test.com')->send(new InviteMail($data));
On my live server this is working fine, but locally I'm getting the following error
FatalThrowableError in UserService.php line 48:
Call to undefined method Illuminate\Mail\MailableMailer::returnPath()
What I've done so far
diff'd both files (local and on the working server): there is no difference
looked up MailableMailer in the docs: https://laravel.com/api/5.3/Illuminate/Mail/MailableMailer.html
the returnPath method indeed doesn't exist on the MailableMailer class
So I'm wondering how this can work on the live server, but locally this throws the error.
I'm trying to use the Mailgun API SDK to send emails from my test server. I downloaded the SDK itself as I am not currently using Composer.
However, when I try to instantiate a Mailgun object, I get this error:
Fatal error: Class 'Mailgun\Connection\RestClient' not found in /var/www/mysite.xyz/www/inc/libs/Mailgun/Mailgun.php on line 38
Which I fixed by adding require "Connection/RestClient.php"; to the Mailgun.php file. However, this in turn caused its own error.
Fatal error: Class 'GuzzleHttp\Client' not found in /var/www/mysite.xyz/www/inc/libs/Mailgun/Connection/RestClient.php on line 41
This is included in my includes.php, so for all pages.
#Mailgun php functions
require_once "libs/Mailgun/Mailgun.php";
use Mailgun\Mailgun;
Then, when I try to use this;
# First, instantiate the SDK with your API credentials and define your domain.
$mg = new Mailgun\Mailgun("key-myactualkey");
$domain = "myactualdomain.xyz";
print "Email to send is ".$welcomeemail; #Never gets reached
It causes those fatal errors and the program grinds to a halt.
Why is this happening and how do I fix it?
I had the same problem and fixed it by using composer which is easier then you might think. Just follow these instructions (locally, on your computer, where PHP should be installed):
https://github.com/mailgun/mailgun-php/blob/master/SharedHostInstall.md
Then upload all files generated to your server in a separate directory.
Then include the following lines to your script:
require 'your/path/to/these/files/vendor/autoload.php';
use Mailgun\Mailgun;
Create a new Mailgun object like this:
$mg = new Mailgun("your-secret-key");
My problem is the next one,
I tried to integrate the google login using OAuth 2.0 feature into my company backend.
I tested it on my domain , www.gabrielestevez.com, everything here works perfect, there is no problem with the require paths, everything runs smothly
But , the company backend directories has the following structure
I'm using a mvc framework developed by me , the Google_SL.php file contains the class where I make the first two require_once
require_once 'Google/Client.php';
require_once 'Google/Service/Oauth2.php';
which works fine, but then when it goes to the client.php and is trying to load this class
require_once 'Google/Auth/AssertionCredentials.php';
is not working , this is the error
An error occurred in script '/home/xxx/public_html/admin/hmf/Core/library/auth/Google/Client.php' on line 18: require_once(Google/Auth/AssertionCredentials.php) [function.require-once]: failed to open stream: No such file or directory
Date/Time: 9-19-2014 11:50:29
, I don't want to change manually all the path within this library because I know there is got to be a better solution to this
any input is appreciated.
for future reference
I fixed my issue using this
set_include_path($_SERVER['DOCUMENT_ROOT'] . '/admin/hmf/Core/library/auth/' . PATH_SEPARATOR . get_include_path());
Try use __DIR__ to get the current directory of the script. Not exactly sure where your AssertionCredentials.php is, but try something like
require_once(__DIR__ . '/Google/Auth/AssertionCredentials.php');
I wan to take all country using Locale from simfony2. In my local host everything work fine, but the problem apear when I upload the site on a live host, is throw this error:
Here is my code:
use Symfony\Component\Locale\Locale;
$countriesArray = Locale::getDisplayCountries('en');
Can someone tell me where is my mistake?
I found where was the problem. In the live host I didn't have installed the intl extension
I'm trying to send an email using PHP from Google App Engine. To send an email, Require Once must include the php file Message.php: See: Code example here at Google
require_once 'google\appengine\api\mail\Message.php';
The Message.php file includes:
require_once 'google/appengine/api/mail/BaseMessage.php';
The BaseMessage.php file in turn requires three other PHP files:
require_once 'google/appengine/api/mail_service_pb.php';
require_once 'google/appengine/runtime/ApiProxy.php';
require_once 'google/appengine/runtime/ApplicationError.php';
So, to recap, Message.php requires BaseMessage.php and BaseMessage.php requires 3 more php files.
Everything works fine until that last PHP file that is required:
require_once 'google/appengine/runtime/ApplicationError.php';
Then a fatal error happens:
Fatal error: Class 'google\appengine\runtime\Error' not found in
C:\Users\UserName\Dropbox\ApplicationName\google\appengine\runtime\
ApplicationError.php on line 22
This is line 22:
class ApplicationError extends Error {
This is code that is provided by Google: the latest PHP SDK for App Engine
It's not code that I wrote. The path to the required files seems to be working, or else I'd get an error msg on the first required file. I've tested require_once lines of code that reference other PHP files in the same directories with no errors. So the issue isn't a problem with the relative path or the PHP.ini file.
My PHP version is Current PHP version: 5.4.22
Windows 7
XAMPP with Netbeans, Apache
How do I fix this problem?
I got the PHP email code to work. I still don't know what the exact problem was to begin with, but it must have something to do with how my Netbeans IDE is currently configured to PHP. The Google App Engine SDK has PHP built into it's installation, but I wasn't running my app from the Google App Engine Launcher. When I ran my app directly from the Google App Engine Launcher, the code worked. I'm guessing that the Netbeans version of PHP was a little different than the Google App Engine SDK version of PHP. And that caused an error in one of the files. In any case, I got the PHP code that sends a email to work. So, the code will run. That tells me that my configuration to PHP in Netbeans probably isn't the same as the configuration to PHP in the version of PHP in the Google App Engine SDK. I might try tweaking the PHP.ini file in netbeans to see if I can link directly to the Google App Engine SDK verion of PHP.