Forums / Code Collaboration / Composer-izing

Composer-izing

Views: 5,789

Results 1 to 7 of 7
8 Mar 2020, 2:06 PM
#1
elslozzo avatar

elslozzo

New Zenner

Join Date:
Feb 2008
Location:
Edmonton, AB
Posts:
60
Plugin Contributions:
1

Composer-izing

Hi All,
I was wondering if anyone uses Composer for things? I do plenty on other projects but it doesn't look like there's much support in Zencart. In trying to make life easier, I started dabbling in a composer-based solution to install/update Zencart but I've simply hit too many obstacles to continue without posting on the forum!

  • There are packages within Zencart that are not in the composer.json file!

Since aura/autoload, ircmaxell/password-compat, square/connect, and PHPMailer/PHPMailer are in Zen Cart core couldn't they be added as Composer dependencies? They live in includes/classes/vendor but could be moved under Composer to live outside of the web root in a vendor/ folder managed by Composer. Thus not requiring developers to update those projects manually and subsequently the parent Zen Cart branch independently.

Which would lead up to my other suggestion of having a "web root" within the project to serve files from. Currently it is the root of the project. Catering to Composer and adjusting for a "web root" things might look like this, with a web folder:

Attachment 18891

And then the web/ folder would be where you point your website root:

Attachment 18892

This folder structure would probably be the first order of business in working toward a Composer plugin. But are there specific reasons why Composer support is minimal? Maybe something else is in the works? **Would a composer plugin or composer branch be of any use to the community **such that "composer create-project zencart" installs this format? (which would obviously require some core edits, eg. filepaths.php)

On the future-future wishlist is plugins (for Composer and Zen Cart) such that this would be possible:

composer update
composer install zencart/usu
composer update zencart/edit_orders

Since downloaded plugins don't have a common structure, this is a long way off. A ZC plugin can contain multiple folders of itself representing different tweaks for different versions of Zen Cart. And these folders can live in sub-folders of the author's choosing, like "common_files" or "zencart_files".

Thoughts and comments welcome! Do you use/like/think Composer is worth it?

9 Mar 2020, 5:16 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Composer-izing

  • There are packages within Zencart that are not in the composer.json file!
    Some work was done in this area in V2 but never moved back to the V1.5 branch. If you don't get any responses on this thread, you might want to open a Github issue and see if any developers respond there.

https://github.com/zencart/zencart/issues

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

9 Mar 2020, 7:59 AM
#3
elslozzo avatar

elslozzo

New Zenner

Join Date:
Feb 2008
Location:
Edmonton, AB
Posts:
60
Plugin Contributions:
1

Re: Composer-izing

Hmmm yeah I've never seen a v2 branch. Too bad because that's encouraging! I figured a post here would get the most eyeballs, and I didn't see any recent development-roadmap type posts (though I'm sure they exist somewhere [perhaps in someone's head!] so here would be the place to start)

Since originally posting I realized that a composer plugin that could install and update plugins would be beyond sweet for so many reasons. Though it may introduce "a new way of doing things" to the point that if the Composer plugin supported patching (which it would) then highly customized Zen Carts could bank their custom patches to be re-applied after updates. Using Composer the usual install/upgrade path may not always require manually comparing files and updating applicable changes post-update with patches.

Using Composer would be conducive for code novices looking to contribute (millenials? kidding not kidding). In general, to transform existing plugins from the Zen-cart.com website into something usable by Composer wouldn't require major code edits and could support multiple versions. A great way to get started!

PS. Just throwing out ideas still at this point.

2 Nov 2021, 1:31 AM
#5
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

Re: Composer-izing

so... also confused. Doing a mod on zen 1.5.7, trying to bring in a UPC scanner with composer, and didn't want a public or guess-able vendors folder, so I moved it along side of public_html... but now I can't access anything like db table constants, functions_lookups.php etc.

I tried including application_top.php but then it just white screen's w/ no errors.

Any thoughts on this?

2 Nov 2021, 2:23 AM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Composer-izing

wolfderby:

so... also confused. Doing a mod on zen 1.5.7, trying to bring in a UPC scanner with composer, and didn't want a public or guess-able vendors folder, so I moved it along side of public_html... but now I can't access anything like db table constants, functions_lookups.php etc.

I tried including application_top.php but then it just white screen's w/ no errors.

Any thoughts on this?
Same result if you happened to temporarily use one of the built in paths? Say, white screens... not a 500 error? Theres a series of steps that can be taken to trouble shoot, which usually involves logging info to the logs folder. First would be to put one such entry just before and just after the call to includes/application_top.php. Would also suggest checking the server logs. It might be an error in the file that results in a php compile like error.

Etc... etc... etc...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

2 Nov 2021, 3:03 AM
#7
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Composer-izing

wolfderby:

so... also confused. Doing a mod on zen 1.5.7, trying to bring in a UPC scanner with composer, and didn't want a public or guess-able vendors folder, so I moved it along side of public_html... but now I can't access anything like db table constants, functions_lookups.php etc.

I tried including application_top.php but then it just white screen's w/ no errors.

Any thoughts on this?

learning ZC loading structure and the like.... hmmm....

your stackoverflow post is good info; but trying to understand it with little experience.... well, it could be tough....

a base ZC install is set to serve everything from DIR_FS_CATALOG. which generally is set to something like:

/var/www/mysite/

or

/var/www/mysite/public_html/

or whatever. it is defined in your configure.php file.

now, if you want to use something OUTSIDE of that directory structure, a base ZC install is not really setup for that. i suppose one could set it up that way, but it gets tricky. ie making use of a file here:

/var/www/mydirectory/

one could very easily use files in a directory as such, and potentially set something up that way, but it is not how ZC is really meant to operate. this is despite the fact that plenty of other frameworks do operate that way.

i am guessing that when you want to require the includes/application_top.php; you are in a file not found situation. as mc stated, your log files will point you to the problem. unfortunately, this is before any ZC log file overrides have taken place; and as such you need to look directly at the apache logs (assuming your server is running apache. if you are running nginx or something else to serve web pages, the logs from that program will have the answer). if you are in a shared hosting situation, my experience varies with getting those logs. but those logs will tell you all.

if i am reading what you are attempting to do correctly, your code should more likely be:

require_once('../mysite/includes/application_top');

.. brings you up one level on the directory structure, so to use that file from another file outside of the DIR_FS_CATALOG, you need to get back to where DIR_FS_CATALOG is, and generally that means up... and then back down....

as to why one wants to operate that way, you can research Security through obscurity which ZC is thoroughly based on. personally, i am not a fan, but that means little as the ZC core team (as well as any number of primary plugin contributors) have embraced it.

https://en.wikipedia.org/wiki/Security_through_obscurity

hope that helps!

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.