Autoloading Php Packages with Hyphens - packagist

Packagist does not allow package names to have capital letters. To workaround this, it recommends using hyphens -. Thus my package name went from TableCreator to table-creator. Unfortunately, this seems to have prevented my library from autoloading with the following error message:
Class 'Company\TableCreator\DatabaseField' not found
This error message disappears as soon as I manually include the specific file rather than relying on the vendor/autoload.php file.
My packages composer.json file is as follows
{
"name": "company/table-creator",
"type": "library",
"description": "Package creating or editing MySQL tables.",
"keywords": ["mysql", "mysqli","models"],
"license": "MIT",
"authors": [
{
"name": "xxx xxx",
"email": "xxx#xxx.org",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"company\\table-creator\\": ""
}
}
}
The namespace declared in the file is still namespace Company\TableCreator;
What do I need to tweak in the composer config for the classes to autload now that the package name has a hyphen?

You need to revert the change to the PSR-4 namespace prefix:
{
"autoload": {
"psr-4": {
"Company\\TableCreator\\": ""
}
}
}

Related

SPFX Package always referring content or resources from localhost instead from CDN

Can someone please let me know from where I can change this configuration so that it should refer from the CDN path instead of localhost
Below is my package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "mega-menu-sp-fx-client-side-solution",
"id": "8f49d75c-5a49-4657-b81b-0290f239350f",
"version": "10.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"features": [
{
"title": "Application Extension - Deployment of custom action.",
"description": "Deploys a custom action with ClientSideComponentId association",
"id": "0d2345df-2a49-4ce9-ba2d-bee7ad3e7a02",
"version": "10.0.0.0",
"assets": {
"elementManifests": [
"elements.xml",
"clientsideinstance.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/mega-menu-sp-fx.sppkg"
}
}
Below is my write-manifest.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "https://Mytenant.sharepoint.com/sites/MyTechTheme/MenuFiles"
}
I tried to figure out whats the issue. For publishing instead of gulp package-solution --ship I had used gulp package-solution so unless and until we don't mention --ship it wont take the references for CDN
So for deploying the package in SPO we need to use gulp bundle --ship and gulp package-solution --ship
As per this thread, to load SPFx assets from a CDN or SharePoint library, set the value of "includeClientSideAssets" to false.
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
...
"includeClientSideAssets": false,
...
}
}

Chef overwrite default attributes of a cookbook

The git cookbook has an error in the url that it uses to download the appropriate version. The url is set in the attributes file as a default attribute so I figured I could just overwrite the url with something static but it does not work. Here is the code from the git cookbook:
case node['platform_family']
when 'windows'
default['git']['version'] = '2.8.1'
if node['kernel']['machine'] == 'x86_64'
default['git']['architecture'] = '64'
default['git']['checksum'] = '5e5283990cc91d1e9bd0858f8411e7d0afb70ce26e23680252fb4869288c7cfb'
else
default['git']['architecture'] = '32'
default['git']['checksum'] = '17418c2e507243b9c98db161e9e5e8041d958b93ce6078530569b8edaec6b8a4'
end
default['git']['url'] = 'https://github.com/git-for-windows/git/releases/download/v%{version}.windows.1/Git-%{version}-%{architecture}-bit.exe'
The cookbook is being included as a dependency in my metadata.rb file and used as a resource in my recipe. It is not part of the runlist. I've tried overwriting the url in my role file like so
"name": "web",
"description": "Web Server Role.",
"json_class": "Chef::Role",
"default_attributes": {
"chef_client": {
"interval": 300,
"splay": 60
},
"git": {
"url": "a test string"
}
},...
That did not work, so I tried adding it to the attributes file of my recipe as a default value, and when that did not work, I tried the override! method which still did not work.
I think the problem is due to the fact that the attribute does not exist when I have declared it, and it gets overwritten by the git recipe.
I don't know how to get around that.
Use override_attributes instead of default_attributes:
"name": "web",
"description": "Web Server Role.",
"json_class": "Chef::Role",
"default_attributes": {
"chef_client": {
"interval": 300,
"splay": 60
}
},
"override_attributes": {
"git": {
"url": "a test string"
}
},...

what is the manifest JSON of the bower package management

On the Site bower.io,it says "There must be a valid manifest JSON in the current working directory." What does that mean? What is a manifest JSON?
This is referring to the bower.json file. This is a a sample of that:
{
"name": "my-project",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"<name>": "<version>",
"<name>": "<folder>",
"<name>": "<package>"
},
"devDependencies": {
"<test-framework-name>": "<version>"
}
}

Execution of a node package command not working on Ubuntu 12.04 RTS

I have created a npm package, Here is the package.json:
{
"name": "docxgen",
"version": "1.0.5",
"author": "Hans Thunam <hans.thunam#gmail.com>",
"description": "A docX Generator",
"contributors": [
{
"name": "",
"email": ""
}
],
"bin":
{
"docxgen":"./docxgenNode/bin/docxgen"
},
"keywords": [
"DocX",
"templates",
"Generator"
],
"dependencies" : {
"xmldom" : "0.1.x"
},
"devDependencies": {
"jasmine-node":"1.10.x"
},
"license": "MIT",
"engines": {
"node": ">=0.8"
}
}
Then I did sudo npm install -g in the folder of package.json, the installation worked correctly (no error nor warnings).
Howewer, when I then try to execute docxgen file.docx file.json, I get the response: File or command not found. What is strange about this is that it works on Windows 7.
Is there anything different to do for Ubuntu ?
The issue was about the character encoding of the ./docxgenNode/bin/docxgen.
The shell system didn't read the first line correctly.
I started from an existing working binary file that can be found here: https://github.com/LearnBoost/stylus/blob/master/bin/stylus

Where to register autoload when the vendor is not managed with composer in Symfony 2.1?

I'm using symfony 2.1 and I want to add a library to vendors. The library do not exists in packagist. I can't manage it with composer. When I install bundles or others vendors through composer, it manage autoload for me. But where to register autoload when the vendor is not managed with composer?
You can add libraries to composer that are not in packagist.
You must add them in the repositories array of your composer.json file.
Here's how to load a github repository that has a composer.json file, even though it's not on packagist (for example a fork you would have done to fix a repository) : http://getcomposer.org/doc/02-libraries.md#publishing-to-a-vcs
And here's how to load a library that's on a git/svn repository, or a zip file : http://getcomposer.org/doc/05-repositories.md#types
An example using various possibilities:
{
"repositories": [
{
"type": "vcs",
"url": "http://github.com/igorw/monolog"
},
{
"type": "package",
"package": {
"name": "smarty/smarty",
"version": "3.1.7",
"dist": {
"url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
"type": "zip"
},
"source": {
"url": "http://smarty-php.googlecode.com/svn/",
"type": "svn",
"reference": "tags/Smarty_3_1_7/distribution/"
},
"autoload": {
"classmap": [
"libs/"
]
}
}
}
],
"require": {
"monolog/monolog": "dev-bugfix",
"smarty/smarty": "3.1.*"
}
}
You should be able to use Composer for registering vendor libraries not available via packagist. I'm not entirely sure, but this should work fine:
{
"autoload": {
"psr-0": {
"Acme": "src/",
"MyVendorLib": "vendor/my-vendor/src",
"AnotherLib": "vendor/another-vendor/lib"
}
}
}
You just need to modify your composer.json file for the autoload value:
http://getcomposer.org/doc/04-schema.md#autoload
//composer.json in your symfony 2.1 project
"autoload": {
"psr-0": {
"": "src/",
"YourLibrary": "src/location/of/lib"
}
},
And then in your controller for example:
namespace Acme\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use YourLibrary\FolderName\ClassName;
class DefaultController extends Controller {
/**
* #Route("/")
* #Template()
*/
public function indexAction()
{
$lib = new ClassName();
$lib->getName();
return array('name' => $name);
}
}

Resources