Cannot start phalcon project on browser - wamp

I use wamp 2.5
I successfully included the phalcon extension by copying the dll file into the ext folder of the wamp php folder , and editing the php.ini file by including extension=php_phalcon.dll. I created a simple project. But when I wanted to open the project on the browser then it shows the list of folders but not the desired page ! Here is the captured photo of the result :
So how to fix it ?
edit :
here is code of the index.php in the public folder :
<?php
use Phalcon\Loader;
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Session\Adapter\Files as SessionFiles;
include("../app/config_const.php");
include("../app/config_inc.php");
include("../app/lib/PSR.php");
require_once RP_BIRT . 'runReport.php';
try {
// Register an autoloader
$loader = new Loader();
$loader->registerDirs(array(
'../app/controllers/',
'../app/models/'
))->register();
// Create a DI
$di = new FactoryDefault();
// Start the session the first time when some component request the session service
$di->setShared('session', function () {
$session = new SessionFiles();
$session->start();
return $session;
});
// Setup the database service
$di->set('db', function(){
$cnx = new DbAdapter(array(
"host" => SERVEUR,
"username" => LOGIN_DB,
"password" => PWS_DB,
"dbname" => BDD
));
return $cnx;
});
// Setup the view component
$di->set('view', function(){
$view = new View();
$view->setViewsDir('../app/views/');
$view->registerEngines(array(
".phtml" => 'Phalcon\Mvc\View\Engine\Volt'
));
return $view;
});
// Setup a base URI so that all generated URIs include the "phalcon" folder
$di->set('url', function(){
$url = new UrlProvider();
$url->setBaseUri('/'.SITE.'/');
return $url;
});
//Register the flash service with custom CSS classes
$di->set('flash', function(){
$flash = new \Phalcon\Flash\Direct(array(
'error' => 'alert alert-error',
'success' => 'alert alert-success',
'notice' => 'alert alert-info',
));
return $flash;
});
//Handle the request
$app = new Application($di);
echo $app->handle()->getContent();
} catch(\Exception $e) {
echo "Exception: ", $e->getMessage();
}
?>
code of ../app/config_const.php :
<?php
define("BDD","resto_vide");
define("SITE", "resto");
define('HTTP_MAIN', 'http://'. $_SERVER["HTTP_HOST"] .'/'.SITE.'/') ;
define('RP_LANG', HTTP_MAIN . 'lang/');
define('RP_SSP', HTTP_MAIN . 'ssp/');
define("SERVEUR",$_SERVER["HTTP_HOST"]);
define("LOGIN_DB","root");
define("PWS_DB","admin");
define("BDD_PORT" ,3306);
define('HTTP_CSS', HTTP_MAIN . "css/");
define('HTTP_JS', HTTP_MAIN . "javascript/");
define('HTTP_IMG', HTTP_MAIN . "images/");
define('HTTP_IMG_LOGO', HTTP_IMG . "logo/");
define('HTTP_IMG_ART', HTTP_IMG . "articles/");
define('HTTP_IMG_TMP', HTTP_IMG . "tmp/");
define('HTTP_IMG_MODE_REGLEMENT', HTTP_IMG . "mode_reglement/");
define('HTTP_IMG_BILLETAGE', HTTP_IMG . "billetage/");
define('HTTP_IMG_CHAMBRE', HTTP_IMG . "chambre/");
define('HTTP_IMG_SALLE', HTTP_IMG . "salle/");
define('HTTP_IMG_TABLE_CLIENT', HTTP_IMG . "table_client/");
define('RP_MAIN', substr($_SERVER["DOCUMENT_ROOT"],-1) == '/' ? $_SERVER["DOCUMENT_ROOT"] . SITE.'/' : $_SERVER["DOCUMENT_ROOT"].'/' . SITE.'/');
define('RP_IMG', RP_MAIN . 'public/images/');
define('RP_IMG_LOGO', RP_IMG . 'logo/');
define('RP_IMG_ART', RP_IMG . 'articles/');
define('RP_IMG_TMP', RP_IMG . 'tmp/');
define('RP_IMG_BILLETAGE', RP_IMG . "billetage/");
define('RP_IMG_CHAMBRE', RP_IMG . "chambre/");
define('RP_IMG_SALLE', RP_IMG . "salle/");
define('RP_IMG_TABLE_CLIENT', RP_IMG . "table_client/");
define('RP_LIB', RP_MAIN . 'app/lib/');
define('CODE_LANG','sess_code_lang');
define('DEFAULT_LANG', '/fr/');
define('RP_RESSOURCES', RP_MAIN . 'app/ressources/');
define('RP_BIRT' , RP_LIB . 'birt/');
define('RP_REPORT' , RP_MAIN . "public/report/");
// SQL server connection information
$sql_details = array(
'user' => LOGIN_DB,
'pass' => PWS_DB,
'db' => BDD,
'host' => SERVEUR
);
?>
code of ../app/config_inc.php :
<?php
require_once RP_LIB . 'ressources.lib.php';
require_once RP_LIB . 'pagination.lib.php';
require_once RP_LIB . 'debug.php';
require_once RP_LIB . 'datetime.lib.php';
require_once RP_LIB . 'mysql.lib.php';
require_once RP_LIB . 'string.lib.php';
require_once RP_LIB . 'numberFormat.lib.php';
require_once RP_LIB . 'file.lib.php';
#ini_alter('error_log', RP_MAIN . 'log/error.log');
#ini_alter('default_charset', 'iso-8859-1');
loadRessource('main') ;
loadRessource('global') ;
?>
code of ../app/lib/PSR.php :
<?php
/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license#phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Piyush Rajesh <mba.piyushgupta#gmail.com> |
| Serghei Iakovlev <sadhooklay#gmail.com> |
+------------------------------------------------------------------------+
*/
namespace Phalcon\Loader;
use Phalcon\Loader;
/**
* Phalcon\Loader\PSR.
* Implements PSR-0 autoloader for your apps.
*
* #package Phalcon\Loader
*/
class PSR extends Loader
{
/**
* Namespace separator
* #var string
*/
protected $namespaceSeparator = '\\';
/**
* Loads the given class or interface.
*
* #param string $className The name of the class to load.
*
* #return bool
*/
public function autoLoad($className)
{
// Reduce slashes
$className = ltrim($className, $this->namespaceSeparator);
$array = explode($this->namespaceSeparator, $className);
if (array_key_exists($array[0], $this->_namespaces)) {
$array[0] = $this->_namespaces[$array[0]];
$class = array_pop($array);
array_push($array, str_replace("_", DIRECTORY_SEPARATOR, $class));
$file = implode($array, DIRECTORY_SEPARATOR);
foreach ($this->_extensions as $ext) {
if (file_exists($file . ".$ext")) {
require $file . ".$ext";
return true;
}
}
}
// If it did not fit standard PSR-0, pass it on to the original Phalcon autoloader
return parent::autoLoad($className);
}
}

The folder you are pointing to doesn't contain an index.php so apache doesn't know to look in your /public/ folder for your index.php. You'd either need to visit http://localhost/resto/public/ to see your site, add an index.php to the base directory (that maybe just includes the one in public) or what is probably best is to create a virtual host that points to your public folder (this does what it would need to in production and makes your business code not directly accessible).
Info on setting up vhosts in WAMP https://john-dugan.com/wamp-vhost-setup/
Phalcon documention for what a vhost should look like https://docs.phalconphp.com/en/3.3/webserver-setup#apache

Related

Creating index with alias

Sorry for the rudimentary question.I'm developing PHP small test class that manipulates AWS Elasticsearch Service.
<?php
namespace MyCompany\Aws;
use Elasticsearch\ClientBuilder;
class ElasticsearchApi {
private $client;
function __construct(string $hosts='', string $username='', string $password=''){
... //configure $this->client
}
/**
* Create index
* #param string $index
* #param array $body
* #return bool
*/
public function createIndex(string $index, array $body = []):bool{
$request = array(
'index' => $index,
'body' => $body
);
$ret = $this->client->indices()->create($request);
return $ret['acknowledged'];
}
}
And call createIndex function specifying alias as described at:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
<?php
require 'vendor/autoload.php';
use MyCompany\Aws\ElasticsearchApi as ES;
$es = new ES();
$body = array('aliases'=>array(
'actions'=>array(
'add'=>array(
'alias'=>'sample-alias',
'index'=>'test-index'
)
)
));
$ret = $es->createIndex('test-index',$body);
var_dump($ret);
This operation normally ends:
PS D:\My_Documents\Proj\Elasticsearch\index-gen> php es-lib-test.php
bool(true)
PS D:\My_Documents\Proj\Elasticsearch\index-gen>
However the generated index does not seem to have alias.
What is wrong with createIndex parameter? I'm using version 7.8 of Elasticsearch on AWS.
Addendum
Based on the #Val 's suggestion, I changed the code as follows:
$body = array(
'aliases'=>array(
'sample-alias'=>array()
)
);
$ret = $es->createIndex('test-index',$body);
var_dump($ret);
However I got the following exception. Are there any mistakes?
PS D:\My_Documents\Proj\Elasticsearch\index-gen> php es-lib-test.php
PHP Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No alias is specified"}],"type":"illegal_argument_exception","reason":"No alias is specified"},"status":400} in D:\My_Documents\Proj\Elasticsearch\index-gen\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\Connection.php:641
Stack trace:
#0 D:\My_Documents\Proj\Elasticsearch\index-gen\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\Connection.php(328): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array)
#2 D:\My_Documents\Proj\Elasticsearch\index-gen\vendor\ezimuel\ringphp\src\Future\CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL)
#3 D:\My_Documents\Proj\Elasticsearch\index-gen\vendor\ezimuel\ring in D:\My_Documents\Proj\Elasticsearch\index-gen\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\Connection.php on line 641
Your body should simply look like this:
$body = array('aliases' => array('sample-alias' => array()));
The syntax you're using is for the _aliases endpoint not for the index creation one.

TYPO3 10 : How can I display the metadata categories of the images in my extension?

I created a TYPO3 extension which allows to select several images. I activated metadata via the filemetadata extension. When I browse the image files in a fluid template loop, I try to display the metadata. This works {file.properties.uid}
{file.properties.categories}, but for the categories I get a number. Now I would like to have the category selected.
I used this:
https://coding.musikinsnetz.de/typo3/fluid-viewhelpers/access-system-categories-in-content-elements-templates
<f: if condition = "{files}">
<f: for each = "{files}" as = "file">
<f: for each = "{bg2yg: CategoriesOutput (recUid: data.uid)}" as = "category">
<b style = 'color: blue'> <span class = "{category.title}"> CATEGORY: {category.title} </span> </b> <br />
</ f: for>
</ f: for>
</ f: if>
This displays the main category because 'data.uid': {bg2yg: CategoriesOutput (recUid: data.uid)}
However, I want the categories of images, I tested this:
<f: for each = "{bg2yg: CategoriesOutput (recUid: file.properties.uid)}" as = "category">
Without success ! Do you have an idea ?
Best regards,
Bruno
thank you for your respective help. Here I coded this:
<?php
/**
* This file is part of the "hexagonalgallery" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BG2YG\Hexagonalgallery\ViewHelpers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* will return certain system categories (sys_category) data of an element
* either as an array or as a string with certain parameters
*
* EXAMPLES:
*
* EMBEDDING IN TEMPLATE: {namespace my = YourVendor\YourExtension\ViewHelpers}
*
* call an array with all category data to be used in a loop, e.g. for an HTML tag for each files:
* <f:if condition="{file}">
* <f:for each="{my:FileCategoriesOutput(recUid: data.uid)}" as="category">
* <span class="{category.title}">{category.title}</span>
* </f:for>
* </f:if>
*
* call a “data-categories” attribute with the slug field of the categories, comma-separated (default):
* {my:FileCategoriesOutput(recUid: file.properties.uid, tableName: 'sys_file_metadata', fieldString: 'title', htmlAttr: 'data-categories')}
* output: ' data-categories="catx,caty"'
*
* call all categories as CSS classes (space as string separator, prefix 'cat-' for each files)
* {my:FileCategoriesOutput(recUid: file.properties.uid, tableName: 'sys_file_metadata', fieldString: 'title', stringSeparator: ' ', catPrefix: 'cat-')}
* output: 'cat-catx cat-caty'
*/
class FileCategoriesOutputViewHelper extends AbstractViewHelper
{
protected $escapeOutput = false;
public function initializeArguments()
{
$this->registerArgument('recUid', 'integer', 'record UID, e.g. of a content element', true);
$this->registerArgument('tableName', 'string', 'optional: table of records you want the categories returned for (default: tt_content)', false, 'tt_content');
$this->registerArgument('fieldString', 'string', 'optional: name of sys_categories table field – if given, the return value will be a string', false, null);
$this->registerArgument('stringSeparator', 'string', 'optional: separator for string', false, ',');
$this->registerArgument('htmlAttr', 'string', 'optional: wrap in attribute for HTML tag (in case of fieldString given)', false, null);
$this->registerArgument('catPrefix', 'string', 'optional: prefix for each category (e.g. for CSS classes)', false, null);
}
/**
* #return mixed
*/
public function render()
{
$recUid = $this->arguments['recUid'];
$tableName = $this->arguments['tableName'];
$fieldString = $this->arguments['fieldString'];
$stringSeparator = $this->arguments['stringSeparator'];
$htmlAttr = $this->arguments['htmlAttr'];
$catPrefix = $this->arguments['catPrefix'];
define(DEBUG,false);
/*
SELECT uid_local FROM sys_file_reference WHERE uid = 152
*/
if (DEBUG)
echo "<b style='color:blue;'>\$recUid=".$recUid."</b><br />";
/**
* default query for sys_file_reference table
* SQL : SELECT uid_local FROM sys_file_reference WHERE uid = $recUid
*/
$queryBuilder0 = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference');
$queryBuilder0->select('uid_local');
$queryBuilder0->from('sys_file_reference');
$queryBuilder0->where(
$queryBuilder0->expr()->eq('sys_file_reference.uid', $queryBuilder0->createNamedParameter($recUid, \PDO::PARAM_INT)));
$result_uid = $queryBuilder0->execute();
$uid=$result_uid->fetch();
$uid=$uid['uid_local'];
if (DEBUG)
echo "<b style='color:blue;'>\$uid=".print_r($uid)."</b><br />";
/**
* default query for sys_category table
*/
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_category');
/**
* select the fields that will be returned, use asterisk for all
*/
$queryBuilder->select('sys_category.uid', 'sys_category.title', 'sys_category_record_mm.uid_foreign', 'sys_category_record_mm.tablenames');
$queryBuilder->from('sys_category');
$queryBuilder->join(
'sys_category',
'sys_category_record_mm',
'sys_category_record_mm',
$queryBuilder->expr()->eq('sys_category_record_mm.uid_local', $queryBuilder->quoteIdentifier('sys_category.uid'))
);
$queryBuilder->where(
$queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)),
$queryBuilder->expr()->like('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter($tableName))
);
$result = $queryBuilder->execute();
$res = [];
$returnString = '';
$i = 1;
while ($row = $result->fetch()) {
$res[] = $row;
if ($fieldString !== null) {
if (isset($row[$fieldString])) {
$returnString .= ($i === 1) ? '' : $stringSeparator;
$returnString .= ($catPrefix !== null) ? $catPrefix : '';
$returnString .= $row[$fieldString];
}
}
$i++;
}
if (DEBUG) {
echo "\$returnString=" . $returnString . "<br />";
echo "\$res=<b style='color:red;'>" . print_r($res) . "</b><br />";
}
if ($returnString !== '') {
return ($htmlAttr !== null)
? ' ' . $htmlAttr . '="' . $returnString . '"'
: $returnString;
} elseif ($fieldString !== null) {
return '';
} else {
return $res;
}
}
}
And it works. Thank you for indicating to me if this code seems to you written in the rules of art.
Best regards,
Bruno
It looks like categories are not handled in the model, so the fastest thing you can do is to create your own ViewHelper for fetching them as suggested in answer to a similar question, my fast test for TYPO3 9.5
IMPORTANT! for ver.: 10+ check annotation changes at the bottom of this post.
<?php
namespace VENDOR\Toolbox\ViewHelpers;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
*
* #package TYPO3
* #subpackage toolbox
* #license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 2 or later
* #author Marcus Biesioroff biesior#gmail.com>
*
* Sample ViewHelper for listing file's categories
*
* Usage:
* {namespace toolbox=VENDOR\Toolbox\ViewHelpers}
* or in ext_tables.php:
* $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['toolbox'] = ['VENDOR\Toolbox\ViewHelpers'];
*
* <toolbox:fileCategories file="{file}" />
* or
* {toolbox:fileCategories(file: file)}
*/
class FileCategoriesViewHelper extends AbstractViewHelper
{
/**
* #var \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository
* #inject
*/
protected $categoryRepository;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('file', 'mixed', 'File');
}
public function render()
{
/** #var FileReference $fileRef */
$fileRef = $this->arguments['file'];
$file = $fileRef->getOriginalFile();
$uid = $file->getUid();
/** #var QueryResult $res */
$res = $this->getCategories($uid);
return $res->toArray();
}
private function getCategories($uid)
{
$query = $this->categoryRepository->createQuery();
$sql = "SELECT sys_category.* FROM sys_category
INNER JOIN sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid AND sys_category_record_mm.fieldname = 'categories' AND sys_category_record_mm.tablenames = 'sys_file_metadata'
INNER JOIN sys_file_metadata ON sys_category_record_mm.uid_foreign = sys_file_metadata.uid
WHERE sys_file_metadata.file = '" . (int)$uid . "'
AND sys_category.deleted = 0
ORDER BY sys_category_record_mm.sorting_foreign ASC";
return $query->statement($sql)->execute();
}
}
So you can use it within your Fluid template like:
<h3>File categories:</h3>
<ul>
<f:for each="{toolbox:fileCategories(file: file)}" as="file_cat">
<li>{file_cat.title}</li>
</f:for>
</ul>
Don't forget to use your own vendor and subpackage key.
Of course, after injecting anything don't forget to flush your caches, sometimes maaaany times.
Important info for ver.: 10.* +
According to this article #inject annotation is depreciated in ver. 9.x and removed in ver." 10.x You should use #TYPO3\CMS\Extbase\Annotation\Inject instead.
So proper injection of the categoryRepository in TYPO3 10.x and newer should look like:
/**
* #var \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository
* #TYPO3\CMS\Extbase\Annotation\Inject
*/
protected $categoryRepository;
You can also search for deprecated annotations within your ext via Upgrade module > Scan Extension Files

How to receive module ID on Opencart frontend

I'm trying to prepare a module.
I need the module_id value.
I will draw data with the module_id value.
How do I get module_id in the controller on the front side.
you should create model file with some name mymodule.php where you should place something like this:
public function getModules() {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` ORDER BY `code`");
return $query->rows;
}
you will get all modules data.
or can get just only one by module code:
public function getModulesByCode($code) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "' ORDER BY `name`");
return $query->rows;
}
Then in your controller with corresponding name mymodule.php file you can call it:
$modules = $this->model_extension_module->getModulesByCode($code);
or
$modules = $this->model_extension_module->getModules();
Your suggestion may apply to single module.
My module has sub-modules.
But I found the solution.
Design layout have solved the work with files.
catalog / controller / common / common_left.php
catalog / controller / common / common_right.php
catalog / controller / common / head_top.php
catalog / controller / common / head_bottom.php
etc.
I added a starred code.
if (isset($part[1])) {
$setting_info = $this->model_setting_module->getModule($part[1]);
if ($setting_info && $setting_info['status']) {
***** $setting_info["module_id"] = $part[1]; *****
$output = $this->load->controller('extension/module/' . $part[0], $setting_info);
if ($output) {
$data['modules'][] = $output;
}
}
}

Sending TWIG output to a zip in Symfony for Templating

I need to create a system that will be able to output a template (a zip with an index.html with all js, css, img etc files as required) based on a set of options (include menu 1, use small footer etc).
So I can put code blocks in so it would not be hard to actually output to the browser the required look, but what if I want to save the rendered html (and this means we would need to change the locations of files like js etc) to a zip instead?
Any ideas? At the moment I'm thinking it would all need to be processed in PHP anyhow (the controller) and TWIG may not be too helpful, but that would make it more complicated.
So I worked this one out, here is the controller to output the required twig zipped:
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
/**
* #Route("/{variableName}", name="homepage"})
*/
public function indexAction($variableName = "Default")
{
//do whatever you need to get the template correct
//send rendered TWIG to a variable
$renderedhtml = $this->render('default/index.html.twig', [
'variableName' => $variableName
])->getContent();
$zipName = "template.zip";
$main = $this->get('kernel')->getRootDir() . '/../web/workingdir/';
$vername = time(); //we use the exact time to get a unique dir name
//remove any projects older than a few minutes (5 in this case)
$dirHandle = opendir($main);
while($item = readdir($dirHandle)){
if(is_dir($main . $item) && $item != '.' && $item != '..') {
if ( ( ( $item + ( 60 * 5 ) ) < $vername ) ) {
system('/bin/rm -rf ' . escapeshellarg($main . $item));
}
}
}
//make the project dir and populate it with files (in this case just the template as index.html, you would want to copy all other files here though)
mkdir($main.$vername);
file_put_contents($main.$vername."/index.html", $renderedhtml);
//create the zip
$zip = new \ZipArchive();
$zip->open($zipName, \ZipArchive::CREATE);
$zip = $this->createZip($zip, $main.$vername);
$zip->close();
//get the zip ready to return
header('Content-Type', 'application/zip');
header('Content-disposition: attachment; filename="' . $zipName . '"');
header('Content-Length: ' . filesize($zipName));
readfile($zipName);
}
// Create a zip with zip object and root dir params (find and include sub-dirs with content)
private function createZip($zip, $source) {
$source = str_replace('\\', '/', realpath($source));
if (is_dir($source) === true) {
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file) {
$file = str_replace('\\', '/', $file);
if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) )
continue;
$file = realpath($file);
if (is_dir($file) === true)
{
$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
}
else if (is_file($file) === true)
{
$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
}
}
}
return $zip;
}
}
Once you get it to this stage, you will just have to add any other required files into the working dir, but I think that could be done under a different issue, this one is about getting the website into a html in a zip.
Hope this helps someone.

how to get the product details in amazon mws?

Hi here is my code please check it and let me know what im missing.
im using amazon orders API for this.
<?php
require_once('.config.inc.php');
//$serviceUrl = "https://mws.amazonservices.com/Orders/2013-09-01";
// Europe
$serviceUrl = "https://mws-eu.amazonservices.com/Orders/2013-09-01";
// Japan
//$serviceUrl = "https://mws.amazonservices.jp/Orders/2013-09-01";
// China
//$serviceUrl = "https://mws.amazonservices.com.cn/Orders/2013-09-01";
$config = array (
'ServiceURL' => $serviceUrl,
'ProxyHost' => null,
'ProxyPort' => -1,
'ProxyUsername' => null,
'ProxyPassword' => null,
'MaxErrorRetry' => 3,
);
$service = new MarketplaceWebServiceOrders_Client(
AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY,
APPLICATION_NAME,
APPLICATION_VERSION,
$config);
$request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
$request->setSellerId(MERCHANT_ID);
// object or array of parameters
echo"<pre>";
print_r($service);
invokeListOrders($service, $request);
function invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request)
{
try {
$response = $service->ListOrders($request);
echo ("Service Response\n");
echo ("=============================================================================\n");
$dom = new DOMDocument();
$dom->loadXML($response->toXML());
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
echo $dom->saveXML();
echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
} catch (MarketplaceWebServiceOrders_Exception $ex) {
echo("Caught Exception: " . $ex->getMessage() . "\n");
echo("Response Status Code: " . $ex->getStatusCode() . "\n");
echo("Error Code: " . $ex->getErrorCode() . "\n");
echo("Error Type: " . $ex->getErrorType() . "\n");
echo("Request ID: " . $ex->getRequestId() . "\n");
echo("XML: " . $ex->getXML() . "\n");
echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
}
}
This is the XMl im using for getting the details i request somebody to reply me as soon as possible.
Just add these two lines after the
$request->setSellerId(MERCHANT_ID);
after this line add these two lines.
$request->setMarketplaceId(MARKETPLACE_ID);
$request->setCreatedAfter('2016-04-01');
Hope this helps..