Trying to use pubnub with lumen - lumen

Im trying to use pubnub with lumen, and failing spectacularly.
Its in the vendor folder under pubnub/pubnub/composer/lib/autoloader.php
Or pubnub/pubnub/composer/lib/Pubnub/Pubnub.php.
How exactly do I access this??
Ive tried puttint it in bootstrap/app.php like so...
require_once __DIR__.'/../vendor/pubnub/pubnub/composer/lib/Pubnub/Pubnub.php';
and...
require_once __DIR__.'/../vendor/pubnub/pubnub/composer/lib/autoloader.php';
That didnt work. I've tried doing that in the actual controller file that I need it in. That didnt work either because of namespacing. I feel like I'm being really stupid right now, but how the hell do I just access this class!?
PS: I don't want to use Broadcasting built into Lumen. As this is just a one off route, that doesnt need all that complexity. I simply just want to fire off a Pubnub simply by loading the class, and doing it.

Related

Setting up Dynamic Links in Firebase with Wordpress site

I am really struggling here... All I actually want to achieve is that I can get the Generate-Strong-Password function inside my app but that is actually harder than I thought.
I learned that I should go with Firebase Dynamic Links because I have a Wordpress-Website from All-Inkl.com.
I followed this Tutorial and there is actually an Apple-Site-Association-File at the moment. But I can't access my Website anymore as it looks like this:
Inside my Firebase Project I am getting this error which says that there not all the necessary "A-Files" are inside my Website:
My DNS-Settings:
I've been struggling for weeks now to get this done so if anyone has any idea how I can fix it I would be extremely grateful!! (btw, I am a total newbie when it comes to websites; I know my way around Swift though)
It seems that different domain providers accept different values for DNS entries ('A records' = 'A-Datensätze', in this case).
Try editing the entries for the Host field (which currently hold your website's URL) to one of the 'common inputs' listed here: https://firebase.google.com/docs/hosting/custom-domain?hl=de#domain-key
As the URL to your site doesn't seem to be what your provider accepts, I would suggest you try replacing it with the next option, i.e. replacing it with # .
Hope this helps solving your issue!

How do relative URLs work in Sinatra?

I am hosting my Sinatra application using Apache with Passenger. It's hosted within a subfolder -- meaning, my main site is example.com, my application is at example.com/popcorn.
So I have a get '/' route, and that works fine. The problem is that my view includes a HTML form that makes a post request to upload, and the post '/upload' route isn't handling it. Instead of example.com/popcorn/upload, it's trying to get example.com/upload.
So I figure okay, not the ideal solution, but for now I'll hardcode the form action URL. But that doesn't work either -- making the action popcorn/upload fails too. This is where I get a little baffled, and my Google-fu was weak, I couldn't find help there.
Maybe I could have some kind of Apache rewrite rule, but is that the correct solution? Am I missing something? I would really appreciate a tip here because it feels like I've messed up something very simple and it's really bugging me.
You probably want the url helper method. That takes into account where the app is mounted on the server:
url('/upload')
The above code will evaluate to something like this:
http://example.com/popcord/upload
Inside your app you shouldn’t need to change anything, this will be routed to the existing post '/upload' handler.

External access to Magento instances

I've started investigating alternatives to my project and a few questions came out that I couldn't answer by myself.
The problem is: I want to create a web page able to access multiple Magento instances installed in the same server. Currently, I have one Magento instance per client and this project will access several Magneto instances to export reports from each one (for example).
The alternatives I thought til this moment are:
Have another Magento instance, create a new module within it that changes its 'database target' before triggering operations/queries;
Questions until this moment:
Can I 'change the database target' of a Magento instance?
How can I access data from a Magento instance without appeal to SOAP/REST?
I want to re-use some components (grids, tabs, forms..) from Magento, that's why I'm not considering an independent project (Zend, for instance) that can access this code from another projects. Does it make sense?
Any other idea?
==Edited==
Thanks by the tips and sorry by my ignorance. The comments let me believe that I'm able to execute something like this:
// File myScript.php
require '/home/DOMAIN1/app/Mage.php';
Mage::app('default');
// get some products from DOMAIN1
require '/home/DOMAIN2/app/Mage.php';
Mage::app('default');
// get some products from DOMAIN2
Is it right? Can I execute require twice (and override things from first require)?
==Edited2==
I'm still trying to connect to several Magento instances from a single third party file. Is there any tip? I'm facing several/different errors at this moment.
The only thing I know is that I can still rely on SOAP to get the information I need, but this will be expensive.
Thanks!
The easiest way would be to include Mage.php from each shop instance. You would need to use namespaces or some other trickery to be able to load more then one.
Or if that doesn't work - make your own API in a separate file to get what you want from one shop, and combine the results in the PHP-file that calls the API.
Here's a sample on how to use Magento functionality outside of Magento:
require 'app/Mage.php';
if (!Mage::isInstalled()) {
echo "Application is not installed yet, please complete install wizard first.";
exit;
}
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// your custom code here, for example, get the product model..
$productModel = Mage::getModel('catalog/product');

ZF2 Album tutorial using stored procedures

Please also suggest which namespace to use. I am new to zend and MVC.
module.php
public function getServiceConfig()
{
// what code here?
}
**Album\Model\Album.php**
{
//what code here?
}
**Album\Model\AlbumTable.php**
{
//what code here?
//do we have to use this class or a different class?
}
I can understand the sudden confusion when starting out with ZF2. However, the manual has really done a good job at helping those who are just starting out. You can find the most up-to-date information here : http://zf2.readthedocs.org/en/latest/user-guide/overview.html
Once you've got the Skeleton Application working I believe some of your confusion will be relieved. If not, come back and ask more specific questions OR you could even join the FreeNode IRC channel at #zftalk.
But to also help answer some of what you've asked here:
getServiceConfig() is where you will interact with the ServiceManager. Try to stay away from closures and work with Factories.
Album.php is sort of like the Hydrator. You don't have to use a Hydrator but for example purposes it was put here. It can make like easier in the long run.
AlbumTable.php is the Database Table you will be interacting with.
The namespace which is used in the tutorial is called Album. The Skeleton application comes packaged with a namespace called Application to start with.
You can manually download ZF2 here: https://packages.zendframework.com/
The latest skeleton application can be found here: https://github.com/zendframework/ZendSkeletonApplication
You may also choose to use Composer to install your entire application which tends to make the installation process much easier for those just starting out, so in your situation I'm going to recommend you use that. You can find instructions on how to use Composer here: http://zf2.readthedocs.org/en/latest/user-guide/skeleton-application.html

Migrate custom Facebook util library to Yii framework

I have a facebook app developed in plain PHP, I'm migrating the app to YII framework.
The thing is that I use a class call "utilsFacebook" where I have the object facebook(of the fb sdk) and all the methods that I need to get data from facebook, getUserId, getUserFriendList, etc.
I don't know how to handle all the operations that I do in utilsFacebook with Yii.
Create a controller with the functions of utilsFacebook is the correct think to do?
Every time that I instance the controller would create a new Facebook object, Should I store that object in a SESSION to get a better performance or is a bad idea?
Q. Create a controller with the functions of utilsFacebook is the correct think to do?
Having done a facebook app using yii as the framework, i would recommend you to make this library either a component, or an extension.
But definitely don't put these functions in the controller directly. Whenever a controller needs them call the functions using your custom facebook util class.
Components can be put in the folder: projectrootfolder/protected/components
Extensions can be put in the folder: projectrootfolder/protected/extensions
If you don't believe that either of these make semantic sense, you can always create a new folder within protected, say utils and put the class there. However i think extensions is the best way to go.
Q. Should I store that object in a SESSION to get a better performance or is a bad idea?
I don't think it's necessary to store the object in a session, because there will be no visible performance gain. Further you'll complicate your code unnecessarily.
What i had done was, created an app level component and used this component throughout the app, in any controller.
Example:
In your application's config, protected/config/main.php :
'components'=>array(
'fbHelper'=>array( // gave the component this name
'class'=>'ext.utils.FacebookHelper', // had stored the helper class in extensions/utils folder
'parameter1'='somevalue',
// more parameters
),
// standard yii app components
),
This will allow you to use the component like this: Yii::app()->fbHelper->getFriends();
Take a look at the facebook-opengraph extension, which could help you, on the way.