I'm using MTHAML and Yii. I have the following lines.
-use yii\helpers\Url
%a{:href => Url::toRoute(['shopping/ping', 'id' => (string)$item->productId, 'category' => (string)$item->primaryCategory->categoryId])} test
However it gives an error.
syntax error, unexpected 'use' (T_USE)
<?php
function __MtHamlTemplate_65307eb071e28021db686cb46d491c8faae477235051858b05f212731637dd40($__variables)
{
extract($__variables);
?><?php use yii\helpers\Url; ?>
I am fixed this bug today.
Update your package by running:
composer update
or download latest release 0.1.3 from GitHub
Because of the namespace invalid when compile html cached.
Please try this from root nb
%a{:href => \yii\helpers\Url::toRoute(['shopping/ping', 'id' => (string)$item->productId, 'category' => (string)$item->primaryCategory->categoryId])} test
Related
I'm trying to create an enrich policy using the Elasticsearch PHP client like so:
$params['name'] = "product-policy";
$params['match'] = [
'match' => [
'indices' => 'products',
'match_field' => 'isbn',
'enrich_fields' => ['title']
]
];
$this->elasticsearch->putPolicy($params);
The Endpoint putPolicy is clearly defined. Can find it here and here
Yet I keep getting this error: Namespace [putPolicy] not found
I'm also not totally sure how to update Elasticsearch-PHP Client to the latest version or how to find the current version install and which one is the latest for that matter. I have put this in composer.json "elasticsearch/elasticsearch": "^7.7" and run composer update which gave me Updating elasticsearch/elasticsearch (v7.11.0 => v7.13.1) while for localhost:9200 I get:
"version" : {
"number" : "7.6.0",
}
Any lead in the right direction with this issue would help a lot. Thank you!
I am using the SDK and _Sample files to test a simple invoice creation.
I am not using composer, so the sample tells me to do this....
include('../config.php');
use QuickBooksOnline\API\Core\ServiceContext;
use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\PlatformService\PlatformService;
use QuickBooksOnline\API\Core\Http\Serialization\XmlObjectSerializer;
use QuickBooksOnline\API\Facades\Invoice;
$dataService = DataService::Configure(array(
'auth_mode' => 'oauth1',
'consumerKey' => "qyprdUSoVpIHrtBp0eDMTHGz8UXuSz",
'consumerSecret' => "TKKBfdlU1I1GEqB9P3AZlybdC8YxW5qFSbuShkG7",
'accessTokenKey' => "qyprdxccscoNl7KRbUJoaJQIhUvyXRzD9tNOlXn4DhRDoj4g",
'accessTokenSecret' => "JqkHSBKzNHbqjMq0Njbcq8fjgJSpfjMvqHVWnDOW",
'QBORealmID' => "193514464689044",
'baseUrl' => "Development"
));
So i have done this on my website, but I get the following error...
ParseError: syntax error, unexpected 'use' (T_USE)
I've literally copied the code above, into a new php file. I have successfully loaded the config.php file.
I have seen elsewhere that a "use" statement must be at the top of the file... it is!
I am trying to send a email using postmarkapp api in php, I have managed to get it to send plain emails. I have uploaded the class to the same directory as index.php but the 'use' function seems to give me a error which is out of my knowledge.
Error:
Parse error: syntax error, unexpected '.', expecting identifier (T_STRING) in /public_html/index.php on line 5
Index.php
// Import the Postmark Client Class.
use Postmark\Models\PostmarkAttachment;
use Postmark\PostmarkClient\.php;
// Create Client
$client = new PostmarkClient("MY API KEY - CENSORED");
// Make a request
$sendResult = $client->sendEmailWithTemplate(
"sender#example.com",
"recipient#example.com",
TEMPLATEID-CENSORED,
[
"product_name" => "product_name_Value",
"name" => "name_Value",
"action_url" => "action_url_Value",
"username" => "username_Value",
"sender_name" => "sender_name_Value",
"product_address_line1" => "product_address_line1_Value",
"product_address_line2" => "product_address_line2_Value",
]);
Same directory Postmark/ I have this class (official class)
https://github.com/wildbit/postmark-php/tree/master/src/Postmark
Thanks for taking the time to read, greatly appreciated.
I think you need 'use Postmark\PostmarkClient;' instead of 'use Postmark\PostmarkClient.php;'
I have a little problem trying to seed my comments table.
I'm 100% sure that I have the Class CommentTableSeeder.php in my /database/seeds directory.
CommentTableSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class CommentTableSeeder extends Seeder {
public function run()
{
DB::table('comments')->delete();
Comment::create(array(
'author' => 'Chris Sevilleja',
'text' => 'Look I am a test comment.'
));
Comment::create(array(
'author' => 'Nick Cerminara',
'text' => 'This is going to be super crazy.'
));
Comment::create(array(
'author' => 'Holly Lloyd',
'text' => 'I am a master of Laravel and Angular.'
));
}
}
Then when I run : php artisan db:seed
I kept getting
I've also try running composer update and run : php artisan db:seed - still get the same result.
Any hints / help will be much appreciated !
You need to run
composer dump-autoload
to fix this error. What this does, among other things, is refreshes the list of classes available to your application.
In this case, while the class did exist in the right location, it was unavailable in your autoloaded class list, and thus returning a Not Found error.
Using PHP GMail OAuth Library/Sample.
$options = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '1.0',
'consumerKey' => $THREE_LEGGED_CONSUMER_KEY,
'callbackUrl' => getCurrentUrl(),
'requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken',
'userAuthorizationUrl' => 'https://www.google.com/accounts/OAuthAuthorizeToken',
'accessTokenUrl' => 'https://www.google.com/accounts/OAuthGetAccessToken'
);
Here's the error: Parse error: syntax error, unexpected ',', expecting '('
This is from line 77: the 'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER, line, any ideas?
Edit: I'm using PHP 4.4.8
You're using PHP 4, which does not support class constants; when it sees code like that, it's expecting a static function call, which it does support:
Class::static_function()
However, in the case of your code, the Zend_Oauth class has a const REQUEST_SCHEME_HEADER, a PHP 5-only feature, which is accessed like so:
Zend_Oauth::REQUEST_SCHEME_HEADER
This is why Zend Framework requires PHP 5. If you intend to use it, yes you'll need to contact your hosting provider to see if they offer PHP 5 as an option or something.
It looks like you are running PHP4.
Most likely your server has both php5 and php4 installed, but it defaults to php4. Contact your server provider.