If this is your first visit, check our documentation. To post, register or login.
Forums / Code Collaboration / how do I require application_top.php in folder in admin with a composer package?

how do I require application_top.php in folder in admin with a composer package?

Started by wolfderby on 28 Dec 2020, 4:51 PM · Views: 18,844

Results 1 to 20 of 59
28 Dec 2020, 4:51 PM
#1
wolfderby avatar

wolfderby

Zen Follower

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

how do I require application_top.php in folder in admin with a composer package?

Buildling in https:127.0.0.1/mysite/admin/myAdminScript

how do I require admin/includes/application_top.php ?

I've tried...

require(https:
require(http:
require(127.
require(DIR . DIRECTORY_SEPARATOR . '..'
require(../includes/application_top.php;);
require(DIR_FS_ADMIN ...1.3.7 style

not sure... just hoping I can require admin login to access an admin folder

question 2, gmail api uses composer to download a rather large vendor folder, compose remove myAdminScript/vendor should help me out, but currently my git repo has too many changes to tracks

trying: https://stackoverflow.com/questions/60160453/vs-code-the-git-repository-has-too-many-active-changes-only-a-subset-of-git-f

any suggestions on that question 2 issue would be awesome, thanks!

28 Dec 2020, 5:02 PM
#2
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,817
Plugin Contributions:
24

Re: how do I require application_top.php in folder in admin with a composer package?

wolfderby:

Buildling in https:127.0.0.1/mysite/admin/myAdminScript

how do I require admin/includes/application_top.php ?

I've tried...

require(https:
require(http:
require(127.
require(DIR . DIRECTORY_SEPARATOR . '..'
require(../includes/application_top.php;);
require(DIR_FS_ADMIN ...1.3.7 style

not sure... just hoping I can require admin login to access an admin folder
If the file is in your admin directory, just use the same logic as all other files have in the admin folder (top level):

require('includes/application_top.php');

Part 2 of the question... Nope. :blink:

My site - Pro ZC Help
My portfolio | My plugins

28 Dec 2020, 5:07 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: how do I require application_top.php in folder in admin with a composer package?

And parentheses not needed for require/include statements.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Dec 2020, 7:39 PM
#4
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

but a simple require('includes/application_top.php'); ends up w/ a Warning: require(includes/application_top.php): failed to open stream: No such file or directory in C:... (because it's a xampp php server run on localhost aka my computer)

so... I need to move up a directory level in the admin, which has an obscured directory path.

28 Dec 2020, 7:41 PM
#5
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

there is no...

/mysite/admin/myAdminScript/includes/application_top.php

...it's in...

/mysite/admin/includes/application_top.php

28 Dec 2020, 7:52 PM
#6
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

this might have worked: require(realpath(DIR . DIRECTORY_SEPARATOR . '../includes/application.php')); but now i'm getting An error occurred: { "error": "unauthorized_client", "error_description": "Unauthorized" } which I think is a credentials.json issue.

28 Dec 2020, 8:33 PM
#7
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,817
Plugin Contributions:
24

Re: how do I require application_top.php in folder in admin with a composer package?

I run everything on xampp so it's not an issue with xampp, but your script.
Now, this seems to be an ajax something, happening from somewhere in your admin directory. This should still work just the same if both your main script file and the processing php file are in the admin root. Perhaps I missed one important part - Buildling in https:127.0.0.1/mysite/admin/myAdminScript - is myAdminScript a directory and then you have all of your php files inside that directory? Honestly, I've never done it like that because I couldn't get it to work either (probably something I don't know how to do), so I opted for the approach where the main php file and the ajax file are in admin root, and the rest of the files can be scattered around. Something like:

  • /admin/my_script.php
  • /admin/my_script_ajax.php
  • /admin/myScriptFolder/everything_else
    Either go that way, or wait for someone else to chip in and share their thoughts. Sorry.

My site - Pro ZC Help
My portfolio | My plugins

28 Dec 2020, 8:33 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: how do I require application_top.php in folder in admin with a composer package?

What purpose is the additional admin sub-directory (/myAdminScript)? My localhost environments normally mimic the associated live site's directory structure, where the /admin sub-directory is at the same 'level' as the storefront /includes sub-directory.

28 Dec 2020, 11:00 PM
#9
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

balihr:

I run everything on xampp so it's not an issue with xampp, but your script.
Now, this seems to be an ajax something, happening from somewhere in your admin directory. This should still work just the same if both your main script file and the processing php file are in the admin root. Perhaps I missed one important part - Buildling in https:127.0.0.1/mysite/admin/myAdminScript - is myAdminScript a directory and then you have all of your php files inside that directory? Honestly, I've never done it like that because I couldn't get it to work either (probably something I don't know how to do), so I opted for the approach where the main php file and the ajax file are in admin root, and the rest of the files can be scattered around. Something like:

  • /admin/my_script.php
  • /admin/my_script_ajax.php
  • /admin/myScriptFolder/everything_else
    Either go that way, or wait for someone else to chip in and share their thoughts. Sorry.

seems like it might go that way then...

28 Dec 2020, 11:01 PM
#10
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

lat9:

What purpose is the additional admin sub-directory (/myAdminScript)? My localhost environments normally mimic the associated live site's directory structure, where the /admin sub-directory is at the same 'level' as the storefront /includes sub-directory.

I'm not sure? first time using google api and composer > "composer require google/apiclient:^2.0"

28 Dec 2020, 11:37 PM
#11
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

...seemed to be a google api vendor folder issue (:

28 Dec 2020, 11:45 PM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: how do I require application_top.php in folder in admin with a composer package?

What's the purpose of adding this api? What are you building?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

29 Dec 2020, 10:17 AM
#13
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

wolfderby:

...seemed to be a google api vendor folder issue (:

^ignore this

I want to set up a cron job to remove my sold amazon inventory using the "Sold, ship now:" emails from amazon sellercentral.

29 Dec 2020, 10:53 AM
#14
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

lat9:

What purpose is the additional admin sub-directory (/myAdminScript)? My localhost environments normally mimic the associated live site's directory structure, where the /admin sub-directory is at the same 'level' as the storefront /includes sub-directory.

So are you saying I should just put it in admin/includes?

29 Dec 2020, 11:50 AM
#15
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

I seem to have it working, I needed to have just tried to copy the design patterns already within the admin instead of forcing through 1 require.

basically shooting for /admin/my_script.php

then...
/admin/includes/classes/custom.php
/admin/includes/functions/maybe.php
/admin/includes/modules/kindaConfusedOnThisDir.php

...when I get closer maybe I'll put it on gitLab and share it for some suggestions.

29 Dec 2020, 12:51 PM
#16
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,817
Plugin Contributions:
24

Re: how do I require application_top.php in folder in admin with a composer package?

wolfderby:

I want to set up a cron job to remove my sold amazon inventory using the "Sold, ship now:" emails from amazon sellercentral.

Uhm... Why do you need to run it in admin then? If it's a cron job, and it's purpose is to adjust stock levels or update order statuses or something similar, why don't you run it from store root? Is there a specific reason why you're placing it in the admin directory?

My site - Pro ZC Help
My portfolio | My plugins

29 Dec 2020, 6:26 PM
#17
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

balihr:

Uhm... Why do you need to run it in admin then? If it's a cron job, and it's purpose is to adjust stock levels or update order statuses or something similar, why don't you run it from store root? Is there a specific reason why you're placing it in the admin directory?

I like the idea of putting the gmail api folder within an admin log-in, for assumed security reasons. Not sure if it'd be a risk or not really.

29 Dec 2020, 8:02 PM
#18
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

...so when i try to move out the includes\gmail\credentials.json it creates a forbidden access 403 error for the .json file if I directly navigate to it, and I'm sure the path is correct.

29 Dec 2020, 8:26 PM
#20
wolfderby avatar

wolfderby

Zen Follower

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

Re: how do I require application_top.php in folder in admin with a composer package?

...within that folder composer (```
composer require google/apiclient:^2.0


<https://developers.google.com/gmail/api/quickstart/php>