Using the Craft CMS Element API V1 - php

I am trying to use the Craft CMS Element API. Due to an older version of PHP I am using version 1 (there is a version 1 branch).
Per the installation instructions I:
1) Uploaded the elementapi/ folder to my craft/plugins/ folder:
2) Went to Settings > Plugins from my Craft control panel and enabled the Element API plugin:
I then followed the setup instructions and created a new elementapi.php file within my craft/config/ folder:
I currently just have the following in my elementapi.php file:
<?php
namespace Craft;
return [
'endpoints' => [
'api/news.json' => [
'elementType' => 'Entry',
'criteria' => ['section' => 'news'],
'transformer' => function(EntryModel $entry) {
return [
'title' => $entry->title,
'url' => $entry->url,
'jsonUrl' => UrlHelper::getUrl("news/{$entry->id}.json"),
'summary' => $entry->summary,
];
},
],
]
];
I tried navigating to http://myUrl/api/news.json, but received the following error: The requested URL /api/news.json was not found on this server.
Any ideas what I may be missing or how I can debug this?

Related

how to use or import ffmpeg in a laravel controller

i have already installed the laravel-ffmpeg via composer in my project
composer require pbmedia/laravel-ffmpeg
then i added class to config/app.php file as documentation says
// config/app.php
'providers' => [
...
ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class,
...
];
'aliases' => [
...
'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class
...
];
then publish this config file
php artisan vendor:publish --provider="ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider"
now my question is to use this package in my project, how should i use this into my controller
i saw many post and ques regarding this and i get these
use FFMpeg;
use FFMpeg\FFMpeg;
use Pbmedia\LaravelFFMpeg\FFMpeg;
use ProtoneMedia\LaravelFFMpeg\FFMpeg;
.
.
.
which one is correct, my goal is to trim a video, but which one works for that i am so confused
//config/laravel-ffmpeg.php
<?php
return [
'ffmpeg' => [
'binaries' => env('FFMPEG_BINARIES', 'ffmpeg'),
'threads' => 12,
],
'ffprobe' => [
'binaries' => env('FFPROBE_BINARIES', 'ffprobe'),
],
'timeout' => 3600,
'enable_logging' => true,
'set_command_and_error_output_on_exception' => false,
];
please help me out, thanks in advance
Use below code in your controller above class
use FFMpeg;
use FFMpeg\Coordinate\Dimension;
use FFMpeg\Format\Video\X264;
Open file using FFMpeg in your controller method
$media = FFMpeg::open($file_path);

Error while taking backup using "spatie/laravel-backup" and using destination disk as Google Drive

I'm using Laravel 5.4 and spatie/laravel-backup v3 and flysystem-google-drive
"nao-pon/flysystem-google-drive": "~1.1"
https://github.com/spatie/laravel-backup
I am able to upload files using
Storage::disk('google')->put('FileName.txt', "hello world");
But with Spatie/laravel-backup package I'm getting the following error while using destination disk as 'google'.
Can you help me regarding this?
Filesystem:
'google' => [
'driver' => 'google',
'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
],
This Is Common Bug When Dealing With Laravel-backup And flysystem-google-drive What I Did To Solve This Problem In Production .
Go To Your .env File :
Change APP_URL=http://localhost To APP_URL= http://YourDomainName
Go To Your /config/backup.php
Change The Line
'name' => config('app.name'),
//To
'name' => env('GOOGLE_DRIVE_FOLDER_ID'),
Now You Should Receive Your Backup
I was getting error "message": "File not found: 6666666Jo8AWLW-LI-XSR5n4z_7KVfNer."
The reason is in the name of the folder that was generated by Google Drive.
Because when I created a new folder, it had a new name "888888RrZx-wXq91XVWd9ZsfrK8X6-yZ" - everything worked.
I think the problem was because of the underscore in GOOGLE_DRIVE_FOLDER_ID.
only pass null name in backup.php
'name' => config('GOOGLE_DRIVE_FOLDER_ID' , ''),
like this will be resolved
'backup' => [
/*
* The name of this application. You can use this name to monitor
* the backups.
*/
'name' => config('GOOGLE_DRIVE_FOLDER_ID' , ''),
'source' => [

TYPO3 Extbase - The configuration file "ext_emconf.php" seems to be invalid

I try to upload my extension but I get Please check your uploaded extension "my_download_plugin". The configuration file "ext_emconf.php" seems to be invalid.
What is supposed to be wrong with this configuration file?
<?php
/***************************************************************
* Extension Manager/Repository config file for ext: "my_download_plugin"
*
* Auto generated by Extension Builder 2017-01-30
*
* Manual updates:
* Only the data in the array - anything else is removed by next write.
* "version" and "dependencies" must not be touched!
***************************************************************/
$EM_CONF[$_EXTKEY] = array(
'title' => 'my_download_plugin',
'description' => 'Downloadlist for my Donwloadcenter',
'category' => 'plugin',
'author' => 'Edward Black',
'author_email' => 'my.name#mycompany.de',
'state' => 'beta',
'createDirs' => '',
'uploadfolder' => false,
'clearCacheOnLoad' => false,
'version' => '2.0.0',
'constraints' => array(
'depends' => array(
'typo3' => '6.2.0-6.3.0',
'static_info_tables' => '6.3.9'
),
'conflicts' => array(),
'suggests' => array()
)
);
I was reading the official documentation but could not find anything wrong.
The TYPO3 version 6.3.0 does not exist. If you want to handle 6.2.x use 6.2.0-6.2.99
Your dependency to static_info_tables seems to be wrong, since you only have given the lower version number. Please add the dependency to static_info_tables like shown below:
'static_info_tables' => '6.3.9-0.0.0'
This will require a minimum version 6.3.9 of static_info_tables extension with no maximum version requirements.
I would prefer to set the version for "static_info_tables" to all for developing purposes.
Next you can add "sjbr/static-info-tables" => "*" to your composer.json.
Install the new dependency.
Now take the package version from the composer.lock-file and add it to your composer.json and now u can fix the version in your ext_emconf.php

elasticsearch-php create index returns \BadRequest400Exception

I have a fresh installation of elasticsearch 5.0.0 and elasticsearch-php . I am trying to create an index.
I run the code from this index management documentation:
$client = ClientBuilder::create()->build();
$params = [
'index' => 'my_index'
];
// Create the index
$response = $client->indices()->create($params);
and it works. I create an index successfully.
I try the next code snippet:
$client = ClientBuilder::create()->build();
$params = [
'index' => 'my_index',
'body' => [
'settings' => [
'number_of_shards' => 3,
'number_of_replicas' => 2
],
'mappings' => [
'my_type' => [
'_source' => [
'enabled' => true
],
'properties' => [
'first_name' => [
'type' => 'string',
'analyzer' => 'standard'
],
'age' => [
'type' => 'integer'
]
]
]
]
]
];
// Create the index with mappings and settings now
$response = $client->indices()->create($params);
and I get:
Elasticsearch\Common\Exceptions\BadRequest400Exception with message 'No handler found for uri [/my_index] and method [POST]'
any ideas why?
This code used to work when I used elasticsearch 2.0
EDIT: I found this question so either it is a problem with elasticsearch-php or I need to update it I guess
I am using elasticquent which I have just realized requires elasticsearch-php version <2.2 so this is what is causing the problem
Looking at the error message:
No handler found for uri [/my_index] and method [POST]
This means that your create index call is using an HTTP POST method under the hood. In previous versions (i.e. pre 5.0), the elasticsearch-php client used to create indices with an HTTP POST but since ES 5.0 only HTTP PUT is accepted to create a new index.
This change back in september made this create call compatible with ES 5.0 again.
The only possible explanation is that you have ES 5.0 installed but you don't have the 5.0 version of the elasticsearch-php client installed.
Since you're running Elasticquent which doesn't yet support ES 5, you can temporarily go around this issue by modifying the Endpoints/Indices/Create.getMethod() method to always return PUT instead of POST and your call will work again, but you might run into other incompatibilities.

Yii2 Kartik Grid View Export Config

Summary: Trying to add export in the for csv & pdf download.
Followed documantation to install. Grid view is otherwise working.
Also added as module in config/web.php's $config array -
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module',
// enter optional module parameters below - only if you need to
// use your own export download action or custom translation
// message source
'downloadAction' => 'gridview/export/download',
'i18n' => [
//'class' => 'yii\i18n\PhpMessageSource',
//'basePath' => '#kvgrid/messages',
//'forceTranslation' => false
]
]
],
N.B: I am using basic template and new in yii2. I have tried other fixes like composer update etc as suggested in various posts but really stuck with the problem.
the thing causing problem is - Yii::t('kvgrid', 'Reset Grid')
Can somene give me a direction here. I guess it is very simple issue :(
You was got above error because of you have not configure i18n component in web.php file.
You need to configure i18n component like as,
'i18n' => [
'translations' => [
'kvgrid*' => [
'class' => 'yii\i18n\PhpMessageSource',
],
]
],
Or uncomment the gridview modules's i18n configuration
'gridview' => [
'class' => '\kartik\grid\Module',
// enter optional module parameters below - only if you need to
// use your own export download action or custom translation
// message source
'downloadAction' => 'gridview/export/download',
'i18n' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '#kvgrid/messages',
'forceTranslation' => true
]
]
You have to replace
Yii::t('kvgrid', 'Reset Grid')
to
Yii::t('app', 'Reset Grid')
in your view file
I suggest better to generate CRUD using the Ajax Crud Generator, it will do all the required task for CRUD and export as well...try this

Categories