I try to install the plugin CakePHP-CSV using Composer. I forked it from ProLoser/CakePHP-CSV.
I don't want to install it in Vendor, but in Plugin folder and with the name of Csv and not the default one that is the plugin name. I tried to use the extra in composer.json but what ever I tried it installs it in Vendor folder of the project.
"repositories": [
{
"type": "package",
"package": {
"name": "CakePHP-CSV/Csv",
"version": "dev-master",
"source": {
"url": "https://github.com/sela/CakePHP-CSV",
"type": "git",
"reference": "origin/master"
}
}
}
],
"require": {
"CakePHP-CSV/Csv": "dev-master",
},
"config": {
"vendor-dir": "Vendor"
},
"extra": {
"installer-paths": {
"Plugin/Cvs": ["Plugin/cvs"]
}
}
You need to make your package depend on composer/installers.
From Composer's documentation:
If you are a package author and want your package installed to a custom directory, simply require composer/installers and set the appropriate type. This is common if your package is intended for a specific framework such as CakePHP, Drupal or WordPress. Here is an example composer.json file for a WordPress theme:
{
"name": "you/themename",
"type": "wordpress-theme",
"require": {
"composer/installers": "~1.0"
}
}
And later (I've added italics to the important part):
As a package consumer you can set or override the install path for a package that requires composer/installers by configuring the installer-paths extra. A useful example would be for a Drupal multisite setup where the package should be installed into your sites subdirectory.
Note that extra is simply a place to put arbitrary data:
Arbitrary extra data for consumption by scripts.
This can be virtually anything. To access it from within a script event handler, you can do:
$extra = $event->getComposer()->getPackage()->getExtra();
The second part is very important; something has to retrieve the extra data and do something with it. In this instance that something is composer/installers.
I needed more space for the code so I answer myself. The following code worked and I didn't need to fork the code.
"repositories": [
{
"type": "package",
"package": {
"name": "ProLoser/CakePHP-CSV",
"version": "1.0",
"type": "cakephp-plugin",
"dist": {
"url": "https://github.com/ProLoser/CakePHP-CSV/archive/master.zip",
"type": "zip"
}
}
}
],
"require": {
"composer/installers": "~1.0.0",
"ProLoser/CakePHP-CSV": "1.*"
},
"config": {
"vendor-dir": "Vendor"
}
Related
I'm currently developing a wallet extension using ReactJS w/bootstrap, I'm trying to build the extension and test it on google chrome, but nothing is rendering.
I thought It might be because I'm using bootstrap and I must add some plugins or script in manifest.json. But I don't have any idea how to.
This is my manifest.json:
{
"manifest_version": 3,
"name": "Wallet",
"author": "whxy",
"version": "1.0.1",
"description": "E-Wallet",
"action":{
"default_title": "E-Wallet",
"default_popup": "index.html",
"default_icon":{
"16":"logo192.png",
"128":"logo192.png"
}
},
"permissions": ["storage"]
}
My expo version is 42.0.0. When I run "expo build:android -t app-bundle", I get this error:
Error: Problem validating fields in app.json. Learn more: https://docs.expo.io/workflow/configuration/
• Field: android - should NOT have additional property 'enableDangerousExperimentalLeanBuilds'.
Couldn't publish because errors were found. (See logs above.) Please fix the errors and try again.
{
"expo": {
"name": "XXXX",
"slug": "XXXX",
"version": "1.2.0",
"orientation": "portrait",
"icon": "./assets/XXXX.png",
"splash": {
"image": "./assets/XXXX.png",
"resizeMode": "contain",
"backgroundColor": "#FBDB5B"
},
"privacy": "public",
"platforms": [
"android"
],
"android": {
"config": {
"googleMobileAdsAppId": "XXXX"
},
"package": "com.XXXX",
"versionCode": 16,
"permissions": [],
"enableDangerousExperimentalLeanBuilds": true
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"]
}
}
The thing is, the property enableDangerousExperimentalLeanBuilds was removed.. https://docs.expo.dev/versions/latest/config/app/#android. Expo wants you to use EAS Build for smaller bundle sizes. You might have to drop the field, otherwise your app might work in development, but then crash once you put it in PlayStore.
Personally, I also had to eject as I wasn't satisfied with the sizes EAS gave me.
I can enable the packages.lock.json files to be generated as described in this link:
https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#locking-dependencies
An example packages.lock.json file may look like this:
{
"version": 1,
"dependencies": {
".NETCoreApp,Version=v3.1": {
"Microsoft.NETFramework.ReferenceAssemblies": {
"type": "Direct",
"requested": "[1.0.0, )",
"resolved": "1.0.0",
"contentHash": "7D2TMufjGiowmt0E941kVoTIS+GTNzaPopuzM1/1LSaJAdJdBrVP0SkZW7AgDd0a2U1DjsIeaKG1wxGVBNLDMw=="
},
"Newtonsoft.Json": {
"type": "Direct",
"requested": "[12.0.3, )",
"resolved": "12.0.3",
"contentHash": "6mgjfnRB4jKMlzHSl+VD+oUc1IebOZabkbyWj2RiTgWwYPPuaK1H97G1sHqGwPlS5npiF5Q0OrxN1wni2n5QWg=="
}
}
}
}
Is there documentation around the schema of this file and what it means? I notice fields like type, resolved, contentHash, etc. under the dependencies node.
Sometimes the nodes might follow these patterns:
"Microsoft.Win32.Primitives": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "9ZQKCWxH7Ijp9BfahvL2Zyf1cJIk8XYLF6Yjzr2yi0b2cOut/HQ31qf1ThHAgCc3WiZMdnWcfJCgN82/0UunxA==",
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0",
"Microsoft.NETCore.Targets": "1.1.0",
"System.Runtime": "4.3.0"
}
}
or
"somenameclient": {
"type": "Project",
"dependencies": {
"SomeNameClientLib": "1.0.0",
"RRRBase": "1.0.0"
}
}
From what I can tell, they have not created or posted a .json schema file for the format of the NuGet packages.lock.json file. The official documentation here makes no mention of it.
The closest thing you will get are:
Description of a lock file
Lock File Format
...from the above link.
I couldn't find this exact situation elsewhere: I have a custom add-on, which I'm loading temporarily via the developer menu. In the manifest file, I'm asking for a lot of permissions already:
{
"manifest_version": 2,
"name": "...",
"version": "1.0",
"description": "...",
"homepage_url": "...",
"permissions": [
"file:///*",
"*://*/*",
"<all_urls>",
"activeTab",
"bookmarks",
"contextMenus",
"tabs"
],
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": {
"19": "icon.svg"
},
"default_title": "..."
}
}
I have a background script only at the moment, however a small content script snippet gets injected:
(function() {
browser.browserAction.onClicked.addListener(async (tab) => {
let executing = browser.tabs.executeScript(tab.id, {
code: "window.getSelection().toString()"
})
...
try {
let selection = await executing
...
} catch(exception) {
console.log(exception)
}
...
})
})()
The purpose is essentially to get the current selection as text (for now) in order to later upload it to a bookmarking service of sorts.
However, when I have a tab open with a PDF file (https://www.example.com/file.pdf or file:///home/foo/file.pdf), the call of the content script to window.getSelection().toString() fails, with the following error:
Error: Missing host permission for the tab
Is this expected and I'm just missing a particular permission (and which one would that be)? Or is it unexpected and possibly worthy of a bug report?
Also, the call works in the developer console, which is why I'm thinking I'm really missing permissions somehow.
I want to install the following plugin and helper via Composer:
https://github.com/cakephp/debug_kit
https://github.com/loadsys/twitter-bootstrap-helper
Here is my composer.json:
{
"repositories": [
{
"type": "package",
"package": {
"name": "cakephp/debug_kit",
"version": "2.0",
"source": {
"url": "https://github.com/cakephp/debug_kit",
"type": "git",
"reference": "origin/2.0"
}
}
},
{
"type": "package",
"package": {
"name": "loadsys/twitter-bootstrap-helper",
"version": "2.1",
"source": {
"url": "https://github.com/loadsys/twitter-bootstrap-helper",
"type": "git",
"reference": "origin/2.1"
}
}
}
],
"require": {
"loadsys/twitter-bootstrap-helper": "2.1.*",
"cakephp/debug_kit": "2.0"
},
"config": {
"vendor-dir": "Vendor/"
},
"autoload": {
"psr-0": {
"DebugKit": "/cakephp/debug_kit/",
"TwitterBootstrap" : "/loadsys/twitter-bootstrap-helper"
}
}
}
The packages are successfully installed at Vendor/cakephp/debug_kit and Vendor/loadsys/twitter-bootstrap-helper
My issues lies in how to I load them in CakePHP. I have the following in my bootstrap.php:
require APP . 'Vendor/autoload.php';
When I attempt to load the Plugin after requiring the autoload with:
CakePlugin::load('DebugKit');
It can not be found. Similar results with loading the helper in my AppController.php with
public $helpers = array('TiwtterBootstrap');
I am a newbie to Composer and am likely missing something simple or just not grasping how to properly load them from the Vendors folder.
Everything you have done is correct, you just need to add an extra section to instruct composer where to install your plugin. Note the extra "installer-paths" sections
, it needs to point to the relative path where you want you plugin be installed.
{
"minimum-stability": "dev",
"config": {
"vendor-dir": "vendors"
},
"extra": {
"installer-paths": {
"app/Plugin/DebugKit": ["cakephp/debug_kit"],
}
},
"require" : {
"php": ">=5.4",
"cakephp/debug_kit": "2.2.*"
}
}
I was rushed this morning in my comment, here is the "extra" block I added to my composer.json:
"extra": {
"installer-paths": {
"Plugin/DebugKit": ["cakephp/debug_kit"],
"Plugin/TwitterBootstrap": ["loadsys/twitter-bootstrap-helper"]
}
Deleting my composer.lock in order to start over with the install, still didn't put the files into the Plugin folder. However, even if I got that to work, I thought it would be possible for the system to recognize the plugins from the Vendor folder via the composer autoload and perhaps some magic from Cake. That way I could just keep the entire Vendors folder out of my repository for this project and update my dependencies as needed.
I ended up solving my issue by just sym linking to these files from the Plugin folder and my system is recognizing the Plugins.