Installed SOLR 5.0 and started the SOLR instance with bin/solr start -e cloud... normal stuff. The web UI is functioning and can see the two nodes.
Created an index file trying to ping the server per Solarium documentation:
require_once ('init.php');
$str="Running Solarium client version: ".Solarium\Client::VERSION;
$client = new Solarium\Client($config);
// create a ping query
$ping = $client->createPing();
var_dump($ping);
// execute the ping query
try {
$result = $client->ping($ping);
$str=$str.'Ping query successful';
var_dump($result->getData());
} catch (Solarium\Exception $e) {
echo 'Ping query failed';
}
return $str;
the $str can show using Solarium client version 3.2.0.
But while doing $client->ping(), there is an exception:
Problem accessing /solr/admin/ping. Reason:
Not Found
Any hints???
config.php pasted here:
<?php
$config = array(
'endpoint' => array(
'localhost' => array(
'host' => '10.0.0.8',
'port' => 8983,
'path' => '/solr/',
)
)
);
It is a remote connection.
I had the same issue. Put collection name in config.php like this:
'path' => '/solr/collection_name/',
Related
I can't download file from google app engine. This is working in Compute engine.
$sql="SELECT * FROM $table ";
$query = $db->runQuery($sql);
if($query->num_rows > 0) {
$delimiter = ",";
$filename = $table . date('Y-m-d') . ".csv";
// create a file pointer
$f = fopen('php://memory', 'w');
// set column headers
$fields = array('id', 'srno', 'empid', 'empname');
fputcsv($f, $fields, $delimiter);
// output each row of the data, format line as csv and write to file pointer
while($row = $query->fetch_assoc()) {
// $status = ($row['status'] == '1') ? 'Active' : 'Inactive';
$lineData = array(
$row['id'], $row['srno'], $row['empid'], $row['empname'], ]
);
fputcsv($f, $lineData, $delimiter);
}
// move back to beginning of file
fseek($f, 0);
// set headers to download file rather than display it
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="' . $filename . '";');
//output all remaining data on a file pointer
fpassthru($f);
}
exit;
What are the logs, error message? How did you deploy this app? Can you show the app.yaml? Is the App in the same project as the Cloud SQL instance? Standard or Flexible environment? PHP 5 or 7?
Most common issues while connecting App Engine to Cloud SQL:
App Engine service account must have the Cloud SQL Admin role
Project in which the Cloud SQL instance resides must have both the Cloud SQL and the SQL Admin API activated
The connection between the app and the MySQL instance is done via proxy, that you configure in your php code and yaml file.
Here is an example of connection to a MySQL instance from PHP72, you can also use this code for local testing. For this you will need to install and run the Cloud SQL Proxy Client.
app.yaml
runtime: php72
handlers:
- url: .*
script: auto
env_variables:
MYSQL_USER: [MYSQL_USER]
MYSQL_PASSWORD: [MYSQL_PASSWORD]
MYSQL_DSN: 'mysql:dbname=[MYSQL_DB_NAME];unix_socket=/cloudsql/[MYSQL_INSTANCE_CONNECTION_NAME]'
beta_settings:
cloud_sql_instances: [MYSQL_INSTANCE_CONNECTION_NAME]
index.php
<?php
$user = getenv('MYSQL_USER');
$password = getenv('MYSQL_PASSWORD');
$dsn = getenv("MYSQL_DSN") ?: "mysql:host=127.0.0.1;port=3306;dbname=[MYSQL_DB_NAME]";
$db = new PDO($dsn, $user, $password);
try {
$db = new PDO($dsn, $user, $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
$statement = $db->prepare("SELECT * from [MYSQL_TABLE_NAME]");
$statement->execute();
$all = $statement->fetchAll();
foreach ($all as $data) {
echo $data["id"];
}
?>
Have a Zend Framework 2.4 connection factory that needs to establish a connection with an AS400 iSeries database. The connection has to be made this way because there are multiple test environment and the factory needs to accommodate each.
The method is using Zend\Db\Adapter\Adapter and I pass that class an array of database connection parameters.
At issue: Zend\Db\Adapter doesn't accept the relational database (directory) name. I'm assuming that since the driver is PDO_IBM, there would be some expectation of a field for explicitly defining the name for the directory.
Here is the method:
public function conn($dbs) {
$this->adapter = new Adapter(array(
'driver' => $dbs['db']['driver'],
'dbname' => $dbs['db']['dbname'],
'username' => $dbs['db']['username'],
'password' => $dbs['db']['password'],
'hostname' => $dbs['db']['hostname'],
'port' => $dbs['db']['port'],
));
var_dump($this->adapter);
return $this->adapter;
}
Adapter is an alias for \Zend\Db\Adapter\Adapter
And here is the object that gets created.
["driver":protected]=> object(Zend\Db\Adapter\Driver\Pdo\Pdo)#224 (4){
["connection":protected]=>object(Zend\Db\Adapter\Driver\Pdo\Connection)#225 (6) {
["driver":protected]=> *RECURSION*
["profiler":protected]=> NULL
["driverName":protected]=> string(3)"ibm"
["connectionParameters":protected]=> array(6) {
["driver"]=> string(7) "PDO_IBM"
["dbname"]=> string(7) “<relational_database_name>”
["username"]=> string(3) “<user_name"
["password"]=> string(3) “<password>"
["hostname"]=> string(9) "127.0.0.1"
["port"]=> string(3) "446"
}
I can instantiate the connection object using:
$conn = new \Zend\Db\Adapter\Adapter( );
Pdo=ibm:<relational_database_name>
But this isn't a workable solution for this situation. Finally, here is the error:
Connect Error: SQLSTATE=42705, SQLConnect: -950 Relational database dbname=;hos not in relational database directory.
For the sake of completeness, here is the configuration that worked for ZF2 Zend\Db\Adapter\Adapter running on Zend Server 6 and connecting to an AS400 iSeries database.
//concat the driver and rel. db directory name into one string
//$dsn name is required for Zend\Db to correctly read it into memory
$dsn = "ibm:" . $db_dir_name;
$this->adapter = new Adapter(array(
'driver' => $driver, // Pdo
'dsn' => $dsn,
'username' => <user_name>,
'password' => <user_pwd>
));
This wasn't documented anywhere and figured it out through trial and error.
I have upgraded to CakePHP 2.5.x series and now trying to implement the new Memcached engine that replaces Memcache; however I am getting the following:
_cake_core_ cache was unable to write 'cake_dev_en-us' to Memcached cache in ...
Uncaught exception 'CacheException' with message ' is not a valid serializer engine for Memcached'
I have updated bootstrap.php and core.php with the correct values. Memcached is working correctly on my Ubuntu 14.04 server using port 11211 on localhost (127.0.0.1). Any help would be appreciated
Thanks
This is because in the Config/core.php, the following 'serialize' parameter will be set as false if the cache engine is set as "Memcached", however, MemcachedEngine requires the 'serialize' to be set among 'php','igbinary' and 'json'. You may just comment out the "serialize" line, so 'php' will be the default value.
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));
/**
* Configure the cache for model and datasource caches. This cache configuration
* is used to store schema descriptions, and table listings in connections.
*/
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration
));
This week I have moved a CakePHP application on the server so that it is served from C:\path\current\ where current is a symlink to C:\path\versions[date]. Previously the app was in C:\inetpub\wwwroot.
Thus each time I deploy changes, I make a new version of the app and the deploy script updates the symlink. In order to avoid having to re-create the temp dir each time, I've moved the temp dir to C:\path\app_tmp\ - the deploy script drops a symlink at app\tmp pointing to this temp dir.
The server is Windows Server 2008 R2 and the web server is IIS7. C:\path\app_tmp\ has full permissions (Everyone has Full Control).
Since making the change to the location of the app and the tmp dir, users are reporting sporadic instances of warnings appearing at the top of the page. The app is in debug=0 but these do not appear in the error log.
Examples:
Warning:
unlink(C:\path\app_tmp\cache\models\prefix_cake_model_default_app_modelname):
Permission denied in
C:\path\versions[date]\www\lib\Cake\Cache\Engine\FileEngine.php on
line 254
Warning:
SplFileInfo::openFile(C:\path\versions[date]\www\app\tmp\cache\models\prefix_cake_model_default_app_modelname):
failed to open stream: Permission denied in
C:\path\versions[date]\www\lib\Cake\Cache\Engine\FileEngine.php on
line 313
(actual paths/model names obfuscated)
Here is what I have in core.php:
$engine = 'File';
$duration = '+999 days';
if (Configure::read('debug') >= 1) {
$duration = '+10 seconds';
}
if (!isset($_SERVER['HTTP_HOST'])) {
$prefix = 'cmd_';
}
else {
$prefix = $_SERVER['HTTP_HOST'] . '_';
}
Cache::config('_cake_core_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_core_',
'path' => CACHE . 'persistent' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666
));
Cache::config('_cake_model_', array(
'engine' => $engine,
'prefix' => $prefix . 'cake_model_',
'path' => CACHE . 'models' . DS,
'serialize' => ($engine === 'File'),
'duration' => $duration,
'mask' => 0666
));
I have this in bootstrap.php:
Cache::config('default', array('engine' => 'File'));
Any suggestions? I have a feeling that perhaps the permissions aren't being inherited properly from the app\tmp symlink to the actual tmp dir, but on the other hand the error logs seem to write correctly and these errors are only sporadic.
One idea i had was to switch to using Wincache but then I can't find any information on how I clear the model cache when I've got a database change to deploy (currently I can just clear the model cache with a grunt task).
I haven't been able to resolve this while sticking to using the default file caching. I've switched the application to using Wincache. To clear model cache when a database change is made, I've written a short script to execute:
Cache::clear('_cake_model_');
This has to be done in the browser because CLI uses a different cache from IIS, but I've made it "gruntable" by using grunt-shell and just executing: start http://script/location/clear_cache
I am trying to use Memcache on NGINX for CakePHP (2.4.7) but when I update the core.php & bootstrap.php to do this I am then thrown the following exception:
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured
I have tried to search if any other configuration is required but can't see anything. Any help would be appreciated
Thanks,
First of all you need be sure that your Memcached configured and working properly.
Check memcached port (11211 if default settings) / process etc... for example memcached -u www-data -vv.
Then if you using memcached default configurations you should change core.php configurations like following:
Uncomment section about memcached. After it it's should looks like this:
Cache::config('default', array(
'engine' => 'Memcache', //[required]
'duration' => 1800, //[optional]
'probability' => 100, //[optional]
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array(
'127.0.0.1:11211'),
'persistent' => true,
'compress' => false));
Now change $engine = 'File'; to $engine = 'Memcache';
Use caching for example in controller you need write data with key => value, then access that data with key. Example:
Cache::write($key, $value);
Cache::read($key);
That's all.
Hope it's help you.