How to not overwrite ext folder with composer install ?

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
MikaelNazarenko
Expert
Posts: 274
Joined: 27 Jun 2019, 16:19

How to not overwrite ext folder with composer install ?

Post by MikaelNazarenko » 27 Jun 2019, 16:21

I have created new Laravel project, there in dependencies is laravel-aimeos. I push files to bitbacket repository, of course I don't push vendor folder.

Normally I work on my local machine. Let say I want to set up this project on remote server. I go to ssh remote server, there clone the project from bitbucket and run composer install.

The problem is when I make composer install not only vendor folder is creating, but also 'ext' folder is creating. Aimeos creates this ext folder. But during development for extending aimeos I need change or create new files inside ext folder. So when I set up the project on another device, I clone the project (there is modified ext folder), then I need make composer install to get vendor and dependencies, and in this moment ext folder gets overwritten.

Stupid situation(

I want to be able to clone project with modified files inside ext folder and make composer install and not get ext folder overwriten.

Aimeos version: 2019.04
PHP Version 7.2.19-1+ubuntu18.04.1+deb.sury.org+1

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: How to not overwrite ext folder with composer install ?

Post by aimeos » 28 Jun 2019, 10:14

The only files you should add/change in your ./ext/ folder are the ones that are in your own extension for your project. Don't touch the other extensions (ai-client-html, etc.) as you can overwrite anything in your own one!

You should add your own extension in ./ext/ to your git repository and ignore anything else using the .gitignore file.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Sergii
Posts: 4
Joined: 03 Nov 2020, 12:41

Re: How to not overwrite ext folder with composer install ?

Post by Sergii » 03 Nov 2020, 13:00

There are several questions about the same topic.

We are working on the project that uses aimeos-laravel 2018.10.4 and want to upgrade it to latest version. But we have some custom code in ext directory, for example, in files like:
- ext/ai-client-html/client/html/src/Client/Html/Common/Client/Summary/Base.php
- ext/ai-client-html/client/html/client/html/templates/catalog/filter/attribute-body-standard.php

some translation files, etc.

After reading messages above, we know that ext should not contain any custom code.
1. So, what is the best way to solve this issue?
2. Should we create something like myextension in the ext directory and move our logic in files with the same names?
If so,
- what namespace should we use?
- how can we make aimeos use our classes, views and translations files instead of that ones in ext directory?

Thanks in advance

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: How to not overwrite ext folder with composer install ?

Post by aimeos » 04 Nov 2020, 08:27

Sergii wrote: 03 Nov 2020, 13:00 After reading messages above, we know that ext should not contain any custom code.
1. So, what is the best way to solve this issue?
2. Should we create something like myextension in the ext directory and move our logic in files with the same names?
Exactly, your own extension should contain all custom code so you can update the installation without loosing it.
Sergii wrote: 03 Nov 2020, 13:00 - what namespace should we use?
- how can we make aimeos use our classes, views and translations files instead of that ones in ext directory?
The namespace of the classes is exactly the same but you have to give your classes a new name and configure that name. The Base classes are problematic because you can't overwrite them (general OOP problem) and you can only overwrite the classes that extend from it.

The templates and translation files are easy because you only have to copy them into the same directory structure in your extension as the original files and they are automagically used.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Sergii
Posts: 4
Joined: 03 Nov 2020, 12:41

Re: How to not overwrite ext folder with composer install ?

Post by Sergii » 05 Nov 2020, 07:13

Thanks a lot for help! We'll try to do it.

Sergii
Posts: 4
Joined: 03 Nov 2020, 12:41

Re: How to not overwrite ext folder with composer install ?

Post by Sergii » 11 Nov 2020, 14:00

After rewriting classes and running "composer dump-autoload" I got such warning about a lot- of classes:
Warning: Ambiguous class resolution, "Aimeos\Client\Html\Catalog\Detail\Standard" was found 2x: in ".../ext/myext/client/html/src/Client/Html/Catalog/Detail/Standard.php" and ".../ext/ai-client-html/client/html/src/Client/Html/Catalog/Detail/Standard.php", the first will be used.
Update: sorry missed this one in your previous post: "The namespace of the classes is exactly the same but you have to give your classes a new name and configure that name."

Could you please tell, if there any doc how to correctly configure names of custom extension's classes?

And is that correct that I placed myext directory inside ext or should they be on the same level?

Thanks in advance

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: How to not overwrite ext folder with composer install ?

Post by aimeos » 12 Nov 2020, 07:34

Sergii wrote: 11 Nov 2020, 14:00 Could you please tell, if there any doc how to correctly configure names of custom extension's classes?
There's a configuration for each component and for the catalog detail it's:
https://aimeos.org/docs/2020.x/config/c ... tail/#name
Sergii wrote: 11 Nov 2020, 14:00 And is that correct that I placed myext directory inside ext or should they be on the same level?
Yes.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Sergii
Posts: 4
Joined: 03 Nov 2020, 12:41

Re: How to not overwrite ext folder with composer install ?

Post by Sergii » 12 Nov 2020, 19:37

Thanks a lot! I managed to do it

Post Reply