How install B2B Suite in Shopware 6? - php

Is it possible to install B2B Suite in Shopware 6 with Composer?
My approach so far has been
composer require shopware/b2b
php bin/console plugin:install SwagB2bPlatform
But this leads to an error when I try to install the plugin
The class "SwagB2bPlatform\SwagB2bPlatform" is not found. Probably an class loader error. Check your plugin composer.json
Does anyone have any experience with this? Do I have to run any scripts to make sure the plugin has all the necessary resources?

Shopware has no way to simple way to require proprietary plugins. You should not use SwagB2bPlatform as composer repository via vcs as all needed assets get packed before the release.
You can setup packages.friendsofshopware.com for your projects. This is a community driven project which provides a repository of all plugins in the community story. You are limited to plugins that you bought in the community store. Using this repository needs an extra entry in the repositories in your composer.json. After that you can just require any plugin that is assigned to your project. In the search you can find the plugin you look out for: https://packages.friendsofshopware.com/?producers=shopware%20AG&term=b2b

Related

How to set up unit testing when developing Directus extensions?

What is a good project setup for developing Directus extensions such as hooks and custom endpoint, while using unit testing with PHPUnit?
Directus extensions live under the same codebase as the core project itself. That's a problem for having the extension code under version control. So what I have now is a symlink from directus/public/extensions/custom/hooks to a directory outside. In there, I have the usual src/ and tests/, and I've done composer install --dev phpunit ^8 and I PHPUnit is in place, and is loading my own classes. Now, how do I bring Directus in here, because Directus is not, AFAIK, on Composer. Maybe make a lib/, checkout Directus from GitHub in there, and have it included in autoload/classmap in composer.json?
Or would it alternatively be better to fork the whole Directus, and use a close of the whole Directus repo for extension dev? How to develop more than one extension?
Or something else?
There is not native testing for directus, the only way is to have the unit testing for php and for vue. Could be so great to have like a integration testing for the modules that uses custom api points. But the idea of directus is that all is modular so nope don't think that's gonna be around soon.

I am installing SiteSupra (CMS) and its dependencies using Php Composer

This is a Symfony Based CMS and require Packages from Git.
I am totally unable figure this out. Please do help, there is a demo site of this cms as well as a Core.
This the repository of Core Base | https://github.com/sitesupra/sitesupra
Hope I Find a Solution
Here's the screenshot of errors I am facing in Composer

How to use Composer dependent software in WordPress?

There are some useful programs written with Composer in mind, meaning the author/s have used some parts of some other program and using Composer it will download these dependencies and make the appropriate configuration, namespacing etc.
I would like to use some of these programs in WordPress in my plugin with using require_once() and including the program(app) so I can use its functions from my WordPress plugin.
How to do that?
I would like to use some of these programs in WordPress in my plugin with using require_once() and including the program(app) so I can use its functions from my WordPress plugin.
Thats possible, but a really bad practice.
You have a plugin folder with a working wordpress plugin.
You add composer.json and require a third-party package.
You trigger composer install and the third-party package gets fetched into the folder vendor inside your plugin folder.
Inside your plugin you include vendor\autoload.php, which is the Composer Autoloader. That's the autoloader for all third-party plugins.
Then you might start to work with third-party classes (without require).
Again, regarding the loading: your plugin is loaded by Wordpress. But your plugin loads its external dependencies itself by including the Composer Autoloader.
When everybody includes Composer packages on the plugin level, then different Wordpress plugins might ship the same Composer packages, right? Ok, lets add 50 different plugins with 10 times the same dependency: crap-ton inside crap-ton.
In other words: including Composer packages directly in plugins works, but is a really bad practice for the Wordpress ecosystem.
The correct way to solve this would be to use Composer on the application level (Wordpress) and not on the plugin level. That means that Wordpress has the vendor folder and all plugins might include code from there - instead of multiple plugins possibly having a vendor folder each.
There are a lot of different approaches out there to handle things a bit more centralized. I really don't know what the current state of Composer integration on the Wordpress core is. That answer is better given by a member of the Wordpress team. In other words: ask for community guidance over at the official Wordpress support.
http://wpackagist.org/
https://github.com/coenjacobs/wordpress-composer-installer
Composer/Installers Wordpress
Lets go through the last one: "Composer Installer for Wordpress"
This installer handles plugin, theme and muplugin package types. See https://github.com/composer/installers/blob/master/src/Composer/Installers/WordPressInstaller.php
How does that work? You need to add a composer.json to your plugin and add "wordpress-plugin" as "type" and require the "composer installer" as a dependency of the package.
{
"name": "my/plugin",
"type": "wordpress-plugin",
"require": {
"composer/installers": "v1.0.6"
}
}
When you run composer install, Composer will fetch the composer/installer and recognize the type "wordpress-plugin". It will then install the plugin into wp-content/plugins/{$name}/.
You can also add more packages to the "require" section.

"plugin" composer project, dependencies to be able to access main project

So I can't quite figure this one out. We have an API as a composer project.
No we which to add functionality to this API in a modular fashion creating separate composer projects for each module.
But how do I resolve dependencies while developing? Each module need access to the "core" API project to be able to test out code.
The current API is not a real composer package yet. But my initial thought is to create a new package for the module I'm about to develope, and then add a dev-dependency for the "core" API.
Or how should I do it?
Are your modules standalone resp. without the "Core" package usable?
I suppose not, so the "Core" module is a dependency for each of your modules.
Ergo the "you/core" package needs to be in the require block of composer.json of every module.
Note that this is not a dev-dependancy then, because i suppose your module wouldnt be usable without the core package.
Phpunit is a classic dev-dependency because the functionality of your module would still work if there would be no phpunit.
To test & develop the module, you would run a composer install in your module project folder to fetch all dependencies into a vendor folder. Then you can develop and have all your dependencies present. You would need to require the composer autoloader, though. F.e in your phpunit.xml.dist.
Dont forget to add vendor to your .gitignore

Zend Framework 2 and source code repository

We created a ZF2 project with skeleton app and it works fine for a simple test application. Now we are working on a real project. My question is what we should store in the repository (SVN), the whole project structure or just the new source code? ZF2 comes with a vendor directory which is almost 31MB in size (which has the ZF libraries). Should we store the whole vendor folder in SVN?
This is the first time we are using PHP and ZF so are not clear in how we will deliver the complete project to production from SVN. Also what is the build process if at all exists. Any clues/links to "ZF2 project packaging" is appreciated.
No, don't include dependencies in your repository! Putting your dependencies under version control doesn't do any good, it just blows up your repo for no reason.
You want to add the skeleton to your repository and your own library but definitely not the framework or any other dependencies.
The way to go is to use composer for dependency installation and some kind of build tool like Phing to automate installation of your project.
See the relevant chapter on phptherightway for more information on how to build your application.
The most simple build process doesn't even need a build tool
checkout your project from SVN/git
run php composer.phar install to install the needed dependencies (defined in your composer.json)
But most probably you want to do some more stuff like setup up the environment, deleting some files, etc.
A word about ZF packages. They're not available from packagist but you can install them with composer anyways. You just have to add the dedicated repository to your composer.json as described here: http://framework.zend.com/downloads/composer

Categories