> So how would you distinguish some of our very obviously "CMS only" classes
> then?
Sorry, I was so fixated on library code that I forgot to mention. My
practice, and one I see a lot, is to have an application specify
namespace for the bespoke application code. Usually a tutorial will
have "use MyApp\Application as Application" or similar.
> For example, we have JApplicationCms extending JApplicationWeb
> (Joomla\Application\AbstractWebApplication in the Framework). Would you
> call that Joomla\Application\AbstractCmsWebApplication or
> Joomla\CMS\Application\AbstractWebApplication?
I'd probably do, in principle, something like:
<?php
namespace Cms;
class TheApp extends \Joomla\Application\AbstractWebApplication
?>
> True, CMS most likely isn't
> needed in the entire API naming structure, but if we continue forward with
> the modularized Framework pieces and have application specific things added
> into the mix, somehow we'll need a way to distinguish them.
There are only two types of code. a) the package you import from
Composer, and b) the code you write that runs the application.
The first lives in /vendor/, the second lives in /api/ (in Joomla 4+).
> The Framework's
> v2 package has a LanguageHelper class right now, the CMS has one too with
> different functions, so one of the two will need a unique name.
If we are talking about Joomla 4, you just put the CMS's version into
a legacy layer.
> I don't know if I would use a folder explicitly named API. Unless you plan
> on dropping the Composer dependencies in there too, it could get confusing
> to explain in some ways.
No, it's really quite simple:
/api - The developers API that the application writes to run itself
/config - File based application configuration files (separate file
for a different configuration namespace, e.g. db.json, mail.json, etc)
/extensions - Where you install addons
/libraries - Legacy library support
/vendor - Imported dependencies
/www - Web root resources
Probably a few more but you get the idea.
> Are developers only allowed to extend code from
> this API or are those vendors also considered part of the API?
Both.
> I personally
> look at the entire top level API as small libraries, and in my "Next" repo,
> I broke the libraries folder into two pieces; core and vendor (core being
> the application specific stuff and vendor being Composer stuff).
Bingo - same concept, different labels.
> It still
> keeps all of the code logically grouped together and since we don't have the
> luxury of shipping the code outside the web root right now and using more
> commonly accepted lib or src folders for our stuff, this feels like an
> appropriate compromise.
If you look at the Node or Bower world for example, /node_modules/ is
top level and everyone knows they are the dependancies and you don't
edit them, but you can include them wherever you want. If in a Joomla
4 scenario, we have the luxury of doing a /www/ folder, then I think
it makes sense to put your custom code (/api/ or whatever) and your
imported dependencies (/vendor) at the top level.
Note, this can't be achieved in 3.x.
Those are my thoughts anyway.
Regards,
Andrew Eddie