Let’s discuss here and define the best way to develop an addon. Then it will become the doc on http://book.agiletoolkit.org/ I think.
The very first question is: How to make an application see addon folders and files i.e. public directory?
Another one is: Where an addon should be? In the /addon folder or /vendor?
Regarding the public directory of the forum. It has been quite a problem in the past. Consider the following structure:
project frontend public index.php atk4 <-- symlink to vendor/atk4/atk4/public/atk4 vendor my-addon public
The public of the project does not have any files from the addon. I am not sure if composer even supports the installation of assets. Having symlinks in a public folder is a good solution for LINUX system, but they totally break Windows. I had to create a instruction to “copy” public into frontend/public and backend/public for the ZIP distribution just to get around symlink problem.
So ideally - composer could be smart enough to recognise a “public” assets inside add-on and symlinking (or copying them if symlinking is not supporting) into project SEVERAL public folders. If we instal add-on using Sandbox, then sandbox could do that manually instead after it executes composer.
As for the location - When you develop add-on put it into shared/addons folder and commit it into your repository. When you are ready to share them with the rest of the world - move them into individual repository, populate them in github / packages, then re-attach them to your projecting composer.json. Typically I’d suggest to use “addon” while you developing your project and after you are done, share the add-ons and relocate them into /vendor.
is it possible to remove using symlinks in ATK at all?
project->addons->myaddon->public directory. Files in the js folder.
My addon consists of some js and css file. How to add this location to pathfinder?
And the pathfinder searches in project public directory.
One more possible way how to have multiple public folders is to use some kind of proxy calls from one (main) public folder. This will need more processing on server side, but then we can avoid symlinks and at the same time have multiple public folders.
$addon_location = $this->app->locate('addons', __NAMESPACE__); $this->app->myaddon_public_location=$this->owner->app->addLocation(array( 'js' =>'public/js', 'css'=>'public/css', )) ->setBasePath($addon_location) ->setBaseURL('../'.$addon_location);