I am trying to get a login redirect in TYPO3 to execute. I first created the vendorname/my_extension stevongo/beleg using Packagist, the php package repository. Next a composer.json on my directory and an ext_emconf.php. I then ran an autoload using composer. And my extention was successfully registered on the autoload_psr4.php i.e.
autoload_psr4.php
....this a testament that both composer.json on my current directory and root directory were well configured same as the ext_emconf.php.
My Classes path is also correctly set as typoconf/ext/beleg/Classes/user_pageNotFound.php
typconf/ext/beleg/Classes
/beleg/Composer.Json
/beleg/ext_emconf.php
My Typoscript is
# Default PAGE object:
page = PAGE
page.10 = USER
page.10 {
userFunc = stevongo\beleg\user_pageNotFound->pageNotFound
}
Initially I had created a Error handling function but after it wasn't executing I changed it to
<?php
namespace stevongo\beleg;
class user_pageNotFound
{
public function pageNotFound()
{
return 'page was not found!';
}
...so as to run a test while maintaining the same class and function name. This simple function at this point is supposed to work but nothing is going.
Any ideas?
Somewhere, a syntax error should show up. The closing curly brace for the class is missing.
Let's say i have one codebase for 500+ clients, based on load balanced web-servers. Each client has their own database, and therefor their own set of credentials.
The easy way here would be to have different .env files with each of the clients credentials and enviornmental settings (this works fine btw), but for optimization reasons, i would like to run the "artisan cache:config" method. This will compile all the config files into a single "config.php" file in /bootstrap/cache".
Now, this is not very functional with lot's of clients. I's it possible to tell Laravel WHERE to look for the cached config file? Without changing core code?
Like defining an enviornmental variable from the vhost "CONFIG_PATH" and (pseudo code)
if( null !== getenv("CONFIG_PATH") && getenv("CONFIG_PATH") != "" ) {
$app->bootstrapConfigPath( getenv("CONFIG_PATH") );
}
Or is the only possibility to have alot of directories, with each their "Bootstrap/cache" folder, and symlinks to the shared codebase ( Which in my opinion is a rather cumberstone path to walk down )
Thanks in advance.
This is possible, but you need to complete a couple of steps. Firstly by extending Illuminate\Foundation\Application with your own application class and overriding the bootstrapPath() method. Then you also have to symlink back to the original bootstrap/app.php from your custom bootstrap folder.
Example
Step 1
/app/Applications/MyApp.php - new custom app class
<?php
namespace App\Applications;
use Illuminate\Foundation\Application as Laravel;
class MyApp extends Laravel
{
public function bootstrapPath($path = '')
{
$bootstrap_env = getenv('APP_BOOTSTRAP');
if(!$bootstrap_env || !file_exists($bootstrap_env) || !file_exists($bootstrap_env.'/app.php')){
dd("Install incomplete, please set bootstrap folder via APP_BOOTSTRAP, make sure the folder exists and the app.php is sym linked");
}
return $bootstrap_env;
}
}
Step 2
/app/bootstrap/app.php - update to instantiate new custom class
- $app = new Illuminate\Foundation\Application(
- realpath(__DIR__.'/../')
- );
+ $app = new App\Applications\MyApp(
+ realpath(__DIR__.'/../')
+ );
Finally
Create custom folders (make sure they are writeable) and a symbolic link of the current app.php to the custom bootstrap location.
mkdir -p /mycustomlocation/bootstrap/cache/
ln -s /laravel/install/bootstrap/app.php /mycustomlocation/bootstrap/app.php
*We couple this with setting a custom .env location using theuseEnvironmentPath() method on the instantiated $app also.
I am integrating google spreadsheet in my project. I have to save form data into google spreadsheet.
For this i am using asimqt php-google-spreadsheet-client library.
I have single form on site that form is submitting using ajax. For this i have written function in function.php.
Getting error when initializing object of DefaultServiceRequest class.
Error: Fatal error: Class 'Google\Spreadsheet\DefaultServiceRequest' not found
require '/vendor/autoload.php';
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;
function spreadsheet_feeds()
{
$access_tok = 'xyz-token';
$serviceRequest = new DefaultServiceRequest($access_tok); // Getting error
ServiceRequestFactory::setInstance($serviceRequest);
$spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
$spreadsheetFeed = $spreadsheetService->getSpreadsheets();
}
add_action( 'wp_ajax_nopriv_spreadsheet_data', 'spreadsheet_feeds' );
add_action('wp_ajax_spreadsheet_data','spreadsheet_feeds');
Any help why this error is occurring because class is already include using "use" statement ?
This seems to be an issue with the location of your vendor folder.
Make sure that the vendor folder is accessible by the file
Considering your folder hierarchy to be
-wp-content
--themes
---your-theme
----functions.php
If you have your vendor folder in your-theme/vendor then in your functions.php
you should write
require 'vendor/autoload.php';
and if vendor is in the root directory of WP make sure you traverse back to the root folder using something like :
require __DIR__ .'/../../../../vendor/autoload.php';
Just replace require '/vendor/autoload.php'; to require_once('vendor/autoload.php');
Just now I tried this here for you myself and it works.
Hi I am new to cassandra database. I am trying to do a project in codeigniter with cassandra database. I have downloaded the phpcassandra files through below link
https://github.com/mauritsl/php-cassandra.
When I am trying to autoload my casssandra.php in codeigniter I got Non-existent class: Cassandra error. Why I got this error and how to solve the issue?
You will need to create a wrapper for it if you wish to use it as a library.
I would suggest you take the composer route.
You can check on packagist for a suitable library.
If you use this particular library phpcassa this is how you would go about getting it to work in Codeigniter.
composer.json
{
"require": {
"php": ">=5.3.0",
"thobbs/phpcassa": "1.1.0"
}
}
index.php
require "../composer/autoload.php";
system/core/codeigniter.php
// Where codeigniter starts to load the Main Controller
// $cassandraDB will be in the GLOBAL scope, so you may want to write a wrapper
$cassandraDB = new ConnectionPool('localhost');
// Then right after this
// if (class_exists('CI_DB') AND isset($CI->db))
// {
// $CI->db->close();
// }
$cassandraDB->close();
User Model
implement it how you wish in your models
public function __construct()
{
//YOU MAY NEED TO PASS $cassandraDB AS A DEPENDANCY!!
$this->users = new ColumnFamily($cassandraDB, 'Standard1');
}
I've been doing a lot of digging around and have ended up with a huge headache and no success. I am trying to use the Zend Amazon Service (within my Codeigniter framework) to fetch information about a book using its ISBN. I initially tried it with Zend 1.12 but I kept getting an error about missing parameter AssociateTag. I am now trying with Zend 2.0 but still getting problems.
This is the code I am using within my controller:
set_include_path(get_include_path() . PATH_SEPARATOR . 'site/libraries');
require_once 'Zend2/Loader/StandardAutoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$amazon = new Zend_Service_Amazon('[apikey]', 'US', '[secretkey]');
$item = $amazon->itemLookup('B0000A432X');
I get the following error:
Fatal error: Class 'Zend_Loader_Autoloader' not found.
My questions are:
How can I load the correct autoloader?
Where do I include the associate tag in the parameters? There is no mention of it in the outdated zend user guide
Zend 2.0 doesn't even seem to have the amazon service files or even the /service folder. What does this mean?
Note: The demo included with zendservice-amazon doesn't work as is. Requests must include your App ID, Secret Key, and Associate Tag which the demo script doesn't do by default. It took me a while to figure this out, without these, all queries throw an exception saying the HTTP response status was 400. Unfortunately the exception doesn't have the response body which says what parameters were missing.
Here is some code that will get you started with ZF2 and ZendService\Amazon.
To start, let me outline the directory structure of where I will be putting files for this example:
testing
|-Zend
|---Crypt
|---Escaper
|---Http
|---I18n
|---Loader
|----+AutoloaderFactory.php
|----+... more files
|----+StandardAutoloader.php
|-----Exception
|---Stdlib
|---Uri
|---Validator
|-ZendRest
|-ZendService
|---Amazon
|-----Authentication
|-------Exception
|-----Ec2
|-------Exception
|-----Exception
|-----S3
|-------Exception
|-----SimpleDb
|-------Exception
|-----Sqs
|-------Exception
|----+AbstractAmazon.php
|----+...more files
|----+SimilarProduct.php
|-+test.php
The gist is I have created a directory called testing where we will place the ZF2 autoloader as well as the Amazon classes and their dependencies. Under testing is a Zend folder that contains the autoloader (in Loader) and also a ZendService folder where the Amazon service goes.
First, we need to get a copy of the autoloader from ZF2. Part of the reason you were having trouble is because it looks like you are using the ZF1 autoloader which is incompatible with ZF2. To get the Autoloader from ZF2, you can download the latest ZF2 package and copy the Loader directory from ZendFramework-2.0.x/library/Zend/ into the Zend folder we created in the testing directory.
Now that we have the autoloader files, let's grab the Amazon service files. I'll write a detailed answer on how to use Composer to get the latest package, but for now I'll explain how to get it manually. To get the full list of available ZF2 packages, load up the JSON file at http://packages.zendframework.com/packages.json In it find, zendframework/zendservice-amazon, determine the highest version available from the list, and grab the corresponding dist. EDIT As of 11th Jul 2013, this is the latest zendservice-amazon package.
From the library directory in ZendService_Amazon-2.0.2.zip, copy the entire ZendService directory into the testing directory. You now have the ZF2 Amazon service files.
Next, take care of the dependencies. From the ZF2 library, copy the directories, Crypt, Escaper, Http, I18n, Json, Stdlib, Uri, and Validator into the Zend directory inside testing.
You will also need the ZendRest package. Copy the ZendRest folder from library from the ZendRest package to testing/ZendRest.
Now for some code. Create test.php inside the testing folder with the following contents:
<?php
require_once './Zend/Loader/StandardAutoloader.php';
$autoloader = new Zend\Loader\StandardAutoloader(array(
'namespaces' => array(
'Zend' => dirname(__FILE__) . '/Zend',
'ZendRest' => dirname(__FILE__) . '/ZendRest',
'ZendService' => dirname(__FILE__) . '/ZendService',
),
'fallback_autoloader' => true));
$autoloader->register();
$tag = 'prdesign-20'; // replace with your Amazon app ID
$appId = '1JT2V3QNEHDAMKYR5F02'; // replace w/ your access key from https://portal.aws.amazon.com/gp/aws/securityCredentials
$secretKey = 'Qgjeiw39f8UNzjJgeerrgDs1a193du/v7djDAtn/x';
$query = new ZendService\Amazon\Query($appId, 'US', $secretKey);
$query->Category('Books')->Keywords('PHP')->AssociateTag($tag);
$result = $query->search();
foreach($result as $item): ?>
<div class="item">
<?php echo $item->Title ?>
by <?php if (is_array($item->Author)): ?>
<?php echo implode(', ', $item->Author) ?>
<?php else: ?>
<?php echo $item->Author ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
First, we require_once the StandardAutoloader class from ZF2. Once the autoloader is registered, this is the only class you have to manually include.
Next, we create a new autoloader and pass some options. This tells the autoloader where classes in the namespace Zend and ZendService are located. We tell the autoloader they live in the respective folders in our current directory. Change dirname(__FILE__) to the correct path as needed. The fallback_autoloader option tells the autoloader to look for classes of any namespace or vendor in the include_path.
Calling $autoloader->register(); then actually registers the autoloader we set up within PHP. Setting up the autoloader is now finished.
The next 3 lines define some required parameters for the API.
The next 3 lines are straightforward, we now create a new instance of ZendService\Amazon\Query and pass our Amazon app ID and secret key. We then build the query by specifying to search in the Books Category and set the Keywords to be PHP. We also add the required AssociateTag. Finally, we execute the search.
I haven't yet used ZendService\Amazon yet so I can't provide detailed instructions on using the class but the included demo script should get you started with sending basic queries to Amazon and processing the results.
Hope that helps.
i have use Amazon AWS S3 bucket along with Zend Framework. A simple example is photo upload to amazon AWS Bucket.In you application/config/application.ini file
;AWSAccessKeyId= "AccessKey"
;AWSSecretKey= "SecretKey"
;AWSS3BucketName = "zoshare-images"
;AWSS3GetImageUrl = "http://[name].s3.amazonaws.com/[folder]/"
Lets say you want to upload an image to bucket, below is sample code of controller
public function updateAction()
{
if($_FILES["fuPic"]["size"] > 0 || $_FILES["fuPre"]["size"] > 0)
{
$config = Zend_Registry::get('config');
$s3 = new Zend_Service_Amazon_S3($config['AWSAccessKeyId'],$config['AWSSecretKey']);
$bucketName = $config['AWSS3BucketName'];
if($_FILES["fuPic"]["size"] == 0)
unset($_FILES["fuPic"]);
else if($_FILES["fuPre"]["size"] == 0)
unset($_FILES["fuPre"]);
$s3->removeObject($bucketName."/[folder]/".$campaignModel->getCampaignId().'_pic_'.$campaign_olddata->getPicture());
$s3->removeObject($bucketName."/[folder]/".$campaignModel->getCampaignId().'_pre_'.$campaign_olddata->getPreview());
if (isset($_FILES["fuPic"]))
{
$filename = $campaignModel->getCampaignId().'_pic_'.$_FILES["fuPic"]['name'];
$s3->putObject($bucketName."/[folder]/".$filename, file_get_contents($_FILES["fuPic"]["tmp_name"]),
array(Zend_Service_Amazon_S3::S3_ACL_HEADER =>
Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ));
$data['picture'] = $_FILES["fuPic"]['name'];
}
if (isset($_FILES["fuPre"]))
{
$filename = $campaignModel->getCampaignId().'_pre_'.$_FILES["fuPre"]['name'];
$s3->putObject($bucketName."/[folder]/".$filename, file_get_contents($_FILES["fuPre"]["tmp_name"]),
array(Zend_Service_Amazon_S3::S3_ACL_HEADER =>
Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ));
$data['preview'] = $_FILES["fuPre"]['name'];
}
}
}
Happy Coding !!!!