im try to install opencart 4 or 3 script but bot give same error. please somebody help me how to fix it. thank you
Warning: is_dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/admin2/.composer:/home/admin2/web/domain.com/public_html:/home/admin2/web/domain.com/private:/home/admin2/web/domain.com/public_shtml:/home/admin2/tmp:/tmp:/var/www/html:/bin:/usr/bin:/usr/local/bin:/usr/share:/opt) in /home/admin2/web/domain.com/public_html/system/storage/vendor/twig/twig/src/Loader/FilesystemLoader.php on line 91
thank you for help yes it worked. but manually installation was not working… there is way to fix version v3 ? because i have a old site backup which i want to use
Reason: Opencart wants to store data outside of the website webroot, for example at /web/private/storage. Therefore the Open Base Dir restriction catches this requirement. Solution: To Get around, you need to create an operational PHP version profile without the restriction. See
for details how to remove the restriction. Also you COULD edit the restriction in the profile, rather than remove, once the private storage is setup.
Also when the popup warning on starting Admin in OC occurs, the default suggestion is “storage” at a root location of your choosing. In practice I discovered that not changing the default, means creating a sub-directory {root}/private/storage. I do not know how the word “private” crept in without my involvement but that is what I had to do, to get it working.
I trust that this makes sense. I am not a OC expert but that is how I got OC working on Hestia and I am very happy with it.
As a follow on, I was not able to install OpenCart on Hestia using the Installer. Too many problems with requires , includes and vendor autoloads not working etc.
I installed from the source code, manually editing some of the config and database config files, before running the install routine, I had no problems to reach /admin where the warnings popped up, related to storage location and renaming the admin folder.
It would not surprise me if the Hestia OpenCart install routine does not make the correct and necessary adjustments to the two config files in between copying the source code and running the install routine.
I am not sure who would have the responsibility for such changes to the Hestia OpenCart installer.
<?php
namespace Opencart\System\Library\Template;
class Twig {
protected string $root;
protected object $loader;
protected string $directory;
protected array $path = [];
/**
* Constructor
*
* @param string $adaptor
*
*/
public function __construct() {
// Unfortunately, we have to set the web root directory as the base since Twig confuses which template cache to use.
$this->root = substr(DIR_OPENCART, 0, -1);
// We have to add the C directory as the base directory because twig can only accept the first namespace/,
// rather than a multiple namespace system, which took me less than a minute to write. If symphony is like
// this, then I have no idea why people use the framework.
$this->loader = new \Twig\Loader\FilesystemLoader('/', $this->root);
}
/**
* addPath
*
* @param string $namespace
* @param string $directory
*
* @return void
*/
public function addPath(string $namespace, string $directory = ''): void {
if (!$directory) {
$this->directory = $namespace;
} else {
$this->path[$namespace] = $directory;
}
}
/**
* Render
*
* @param string $filename
* @param array $data
* @param string $code
*
* @return string
*/
public function render(string $filename, array $data = [], string $code = ''): string {
$file = $this->directory . $filename . '.twig';
/*
* FYI all the Twig lovers out there!
* The Twig syntax is good, but the implementation and the available methods is a joke!
*
* All the Symfony developer has done is create a garbage frame work putting 3rd party scripts into DI containers.
* The Twig syntax he ripped off from Jinja and Django templates then did a garbage implementation!
*
* The fact that this system cache is just compiling php into more php code instead of html is a disgrace!
*/
$namespace = '';
$parts = explode('/', $filename);
foreach ($parts as $part) {
if (!$namespace) {
$namespace .= $part;
} else {
$namespace .= '/' . $part;
}
if (isset($this->path[$namespace])) {
$file = $this->path[$namespace] . substr($filename, strlen($namespace) + 1) . '.twig';
}
}
// We have to remove the root web directory.
$file = substr($file, strlen($this->root) + 1);
if ($code) {
// render from modified template code
$loader = new \Twig\Loader\ArrayLoader([$file => $code]);
} else {
$loader = $this->loader;
}
try {
// Initialize Twig environment
$config = [
'charset' => 'utf-8',
'autoescape' => false,
'debug' => false,
'auto_reload' => true,
'cache' => DIR_CACHE . 'template/'
];
$twig = new \Twig\Environment($loader, $config);
return $twig->render($file, $data);
} catch (Twig_Error_Syntax $e) {
throw new \Exception('Error: Could not load template ' . $filename . '!');
}
}
}
.........................................................................................................................................................................................................................................................................................................................................................................
It is not clear to me what exactly needs to be replaced and by what though?
I do have some experience in modifying Opencart 2.1.0.1. core files, which is the version I currently am using, but
"sed -i.original "s|'/', \$this->root|'\./', \$this->root|" does not make any sense to me at the moment.
After reading the notes by the developers in that particular twig file, it is pretty clear that they are not at all impressed with it either. Personally speaking I do not like trying to fix things that ain’t broken which is why I remain using Opencart version 2.1.0.1. It works perfectly well on PHP versions from 5.6 onwards and has no issues at all as far as I can tell.
One plus factor of using an old version like that is that a lot of the extensions are now free also, whereas those using a newer version of Opencart have to pay $20 for them!