i'm installing PicoFeed from composer with this configuration on composer.json
"repositories": [
{
"type": "package",
"package": {
"name": "fguillot/picoFeed",
"version": "dev-master",
"source": {
"url": "https://github.com/fguillot/picoFeed",
"type": "git",
"reference": "origin/master"
}
}
}
],
"require": {
"laravel/framework": "4.2.*",
"fguillot/picoFeed": "dev-master"
},
now i think i must be define this class into app.php such as providers and aliases after set this line
'Reader' =>'fguillot\picoFeed\picofeed',
in aliases and try to use :
Route::get('/feed', array('as' => 'feed', function () {
try {
$reader = new Reader;
$resource = $reader->download('http://linuxfr.org/news.atom');
$parser = $reader->getParser(
$resource->getUrl()
);
$feed = $parser->execute();
echo $feed;
}
catch (Exception $e) {
echo $e;
}
}));
i get this error:
exception 'ErrorException' with message 'Class 'fguillot\picoFeed\picofeed' not found' in /var/www/livedata/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php:64
how to add this class to providers on app.php file
You are not using the right class
'Reader' => 'PicoFeed\Reader\Reader';
Or
'Reader' => PicoFeed\Reader\Reader::class;
try this. If you have a IDE like phpstorm you will see warning if its not there.
Related
I'm writing a library which makes use of GuzzleHttp. The library sits inside of a composer package:
composer.json
"require": {
// ...
"adz/test": "^1.0#dev",
// ...
}
./vendor/adz/test/composer.json
"require": {
"php": "~5.6|~7.0",
"guzzlehttp/guzzle": "^6.3"
},
library controller
namespace adz\test;
use GuzzleHttp\Client;
class User
{
static $client;
public function __construct()
{
self::$client = new \GuzzleHttp\Client();
}
public static function getAll()
{
$res = self::$client->request('GET', 'https://jsonplaceholder.typicode.com/users');
return $res->getBody();
}
}
front controller
use adz\test\User;
class UserController extends Controller
{
var $user, $allUsers;
public function __construct()
{
$this->user = new User();
}
public function getAll()
{
$allUsers = $this->user::getAll();
echo $allUsers;
}
}
At run-time the application reports:
Class 'GuzzleHttp\Client' not found.
If I
composer require guzzlehttp/guzzle
in my front composer.json, then Guzzle works fine. But I don't want to load Guzzle into my front composer.json.
I only want to load Guzzle in my library composer.json file.
What should I do?
Edit: (./vendor/adz/test/composer.json) - full version;
{
"name": "adz/test",
"type": "library",
"description": "desc",
"keywords": [
"adz",
"test"
],
"homepage": "https://github.com/adz/test",
"license": "MIT",
"authors": [
{
"name": "Andy",
"email": "andy#gmail.com",
"homepage": "https://github.com/1cookie",
"role": "Developer"
}
],
"require": {
"php": "~5.6|~7.0",
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"phpunit/phpunit" : ">=5.4.3",
"squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
"psr-4": {
"adz\\test\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"adz\\test\\": "tests"
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs src tests",
"fix-style": "phpcbf src tests"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
}
}
I try to create a package but for some reason, I cannot access the front-end.
This is my package structure, from the project root directory:
/package/contact/src/routes/web.php
/package/contact/composer.json
/package/contact/ContactServiceProvider
The service provider class looks like the following:
namespace Sidneylab\Contact;
use Illuminate\Support\ServiceProvider;
class ContactServiceProvider extends ServiceProvider
{
public function boot(){
$this->loadRoutesFrom(__DIR__.'/routes/web.php');
}
public function register(){
}
}
Composer.json
"name": "sidneylab/contact",
"description": "This will send email to admin and send contact query to database",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Sidney de Sousa",
"email": "esp.sousa#gmail.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {
"Sidneylab\\Contact\\": "src/"
}
},
web.php
Route::get('contact', function(){
return "contact";
});
In my main composer.json file I added this:
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/",
"Sidneylab\\Contact\\": "package/contact/src"
}
},
Also, I imported the service provider inside my confi/app.php
Sidneylab\Contact\ContactServiceProvider::class
Now, when I hit my url/contact it does not return anything. Anything I could have possibly missed?
Anything to do with the things I named?
I see that there is no documentation how to add custom CKEditor plugins into Bolt CMS.
Can i add/modify files in public/bolt-public/ folder?
In public\bolt-public\view\js\ckeditor\config.js file i see the following:
// CKeditor config is done in /app/src/js/bolt.js.
but in my yet installed bolt cms i dont have any /app/src/js/bolt.js file to modify.
Can someone help me out to get for example this plugin working in my Bolt CMS?
https://www.michaeljanea.com/ckeditor/font-awesome
Here i found a solution to customize CKEditor and add plugins like FontAwesome.
First we need to create Bold Extension.
Create extension folder /extension/local/mycompany/customckeditor.
In this extension folder we need to create subfolders
/src
/web
/web/plugins
After we need to create Bolt extension file src/CustomCkeditorExtension.php
<?php
namespace Bolt\Extension\MyCompany\CustomCkeditor;
use Bolt\Asset\File\JavaScript;
use Bolt\Extension\SimpleExtension;
use Bolt\Controller\Zone;
/**
* Custom CKEditor extension class.
*/
class CustomCkeditorExtension extends SimpleExtension
{
/**
* {#inheritdoc}
*/
protected function registerAssets()
{
$asset = new JavaScript();
$asset->setFileName('/extensions/mycompany/customckeditor/ckeditor-extended.js')
->setLate(true)
->setPriority(99)
->setZone(Zone::BACKEND);
return [
$asset,
];
}
}
Create composer file /extension/local/mycompany/customckeditor/composer.json
{
"name": "mycompany/customckeditor",
"description": "An extension to allow for CKEditor customisations.",
"type": "bolt-extension",
"version": "1.0.0",
"keywords": [
"ckeditor"
],
"require": {
"bolt/bolt": "^3.4"
},
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"license": "MIT",
"authors": [
{
"name": "Bogdan",
"email": "info#youremail.com"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Bolt\\Extension\\MyCompany\\CustomCkeditor\\": "src"
}
},
"extra": {
"bolt-assets": "web",
"bolt-class": "Bolt\\Extension\\MyCompany\\CustomCkeditor\\CustomCkeditorExtension"
}
}
Go to your console to /extensions folder and edit composer.json file.
Add this lines:
"repositories": {
...
"mycompany-ckeditor-git-repo": {
"type": "path",
"url": "local/mycompany/customckeditor",
"options": {
"symlink": false
}
},
...
},
"require": {
...
"mycompany/customckeditor": "^1.0",
...
}
After that run:
$ composer update
Create JS file /web/ckeditor-extended.js
if (typeof CKEDITOR !== 'undefined') {
CKEDITOR.dtd.$removeEmpty['span'] = false;
}
jQuery(document).ready(function ($) {
var CKEDITORPluginExtras = false;
if (typeof(CKEDITOR) != 'undefined') {
CKEDITOR.plugins.addExternal('fontawesome', '/extensions/mycompany/customckeditor/plugins/fontawesome/plugin.js', '');
CKEDITOR.on('instanceReady', function (event, instance) {
if (CKEDITORPluginExtras) {
return;
}
var config = event.editor.config,
name;
config.toolbar.push(
{ name: 'insert', items: [ 'FontAwesome' ] }
);
config.contentsCss.push(CKEDITOR.plugins.getPath('fontawesome') + 'font-awesome/css/font-awesome.min.css');
config.extraPlugins += (config.extraPlugins ? ',' : '') + 'widget,fontawesome';
for (name in CKEDITOR.instances) {
if (CKEDITOR.instances.hasOwnProperty(name)) {
CKEDITOR.instances[name].destroy();
CKEDITOR.replace(name, config);
}
}
CKEDITORPluginExtras = true;
});
}
});
Copy fontawesome.zip content to /web/plugins
And finally reload your admin panel.
This is my composer.json file:
{
"name": "******",
"description": "*****",
"license": "****",
"authors": [
{
"name": "****",
"email": "****#gmail.com"
}
],
"minimum-stability": "dev",
"require": {
"php":">=5.0.1",
"lib-libxml":">=2.9.2"
},
"autoload": {
"psr-4": {
"****\\": "src/"
}
}
}
The class included has this
class ****
{
protected $element;
/**
* Contstruct XML.
*/
public function __construct()
{
$this->element = new SimpleXmlElement('<ADF/>');
}
...
And the test run results is this
Fatal error: Class *****\SimpleXmlElement' not found
As stated here https://getcomposer.org/doc/02-libraries.md. What have I missed, and how can I fix it?
If I remove the require entries (php and lib-libxml), the result is still the same.
Add a backslash at the beginning of SimpleXmlElement; this will ensure that PHP doesn't check your source folder for the SimpleXmlElement class:
$this->element = new \SimpleXmlElement('<ADF/>');
Documentation
this is the composer.json of my bundle (shortened)
{
"name": "acme/my-bundle",
"type": "library",
"version": "0.5.0",
"autoload": {
"psr-4": {
"Acme\\MyBundle\\": ""
}
}
}
and in my project:
"require": {
"acme/my-bundle": "dev-master"
},
then i run composer install resulting in a installed.json like
[
{
"name": "acme/my-bundle",
"version": "dev-master",
"version_normalized": "9999999-dev",
"type": "library",
"installation-source": "source"
//
// here must be this:
// "autoload": {
// "psr-4": {
// "Acme\\MyBundle\\": ""
// }
// },
// but these lines are missing!
//
}
]
and a autoload-psr4.php:
<?php
// autoload_psr4.php #generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
/* here must be this:
* 'Acme\\MyBundle\\' => array($vendorDir . '/acme/my-bundle'),
* but this line is missing!
*/
);
the autoload is gone, and also other keys like require
what am i missing?
i also tried psr-0, but no success. autoload_namespaces.php is just an empty array.
I did not mention, that I wanted to fetch a package from a private repo! This will make the difference!
So I had to re-specify the autoload
"require": {
"acme/my-bundle": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"version": "dev-master",
"name": "acme/my-bundle",
"source": {
"url": "ssh://git#example.com/acme/my-bundle",
"type": "git",
"reference": "test"
},
// THIS IS |
// ADDITIONAL V
"autoload": {
"psr-4": {
"Acme\\MyBundle\\": ""
}
}
}
}
]
see https://stackoverflow.com/a/24193122/816362
Thanks #zacharydanger