unable to load Assetes class with MY_Assetes in same directory - php

i have one third party asset library in my application folder, i am extending that library with MY_Assets library both are in same application/library directory, but when loading its giving error Unable to load the requested class: Assets, i want to add some extra features in library by extending it so if developer of main library make any update nothing effect to mine extension

Place the file in application folder and need to include the code manually then extends from it.
See the below code that I uses for extending the Facebook connect for Codeigniter.
include(APPPATH.'libraries/facebook/facebook.php');
class Fb_connect extends Facebook{
//my coding here
}
Here I have a folder named facebook inside the libraries folder for facebook related dowloaded files and FB_connect.php is my library file it is in application /libraries folder and fb_connect class that inherits from Facebook class.

Related

PS-4 PHP package - Main folder classes are not able to access the sub folder classes - Namespace

I am learning to setup PHP package with PSR-4 autoload using composer. I have managed to set up the working package. But I can access the classes in the same directory but cannot access the sub folder classes from main folder class.
adding my src code link here https://github.com/nsatheesh87/PSR-4-PHP-Test
Kernel.php from src directory trying to access the Http->Request.php class but only i can get Class cannot found error. Also I Checked the namespaces
You miss parameter with create Kernel object
https://github.com/nsatheesh87/PSR-4-PHP-Test/blob/master/src/app.php#L14
This constructor require object of Request class
https://github.com/nsatheesh87/PSR-4-PHP-Test/blob/master/src/Kernel.php#L11

According to this tutorial where have I to create this class in my Laravel project (a class implementing the UserProviderInterface interface)

I am abslolutly new in PHP and moreover in Laravel framework (I came from Java).
I am following this tutorial to create a custom authentication driver:
http://laravel-recipes.com/recipes/115/using-your-own-authentication-driver
I have a very newbye doubt: at the beginning of this tutorial it show that I have to create a class that implements UserProviderInterface.
It only show the code but not where this class have to be put into my Laravel project. The only clue about its positioning is the namespace:
namespace MyApp\Extensions;
But exactly where have I to put it?
I have the following structure:
It say to put it into MyApp\Extensions but I have not MyApp and Extension folder in my project? (or maybe the nampespaces name doesn't reflect a directory structure into the project tree?)
So where have I to create this class?
if you want it to go inside MyApp\Extensions, consider MyApp as the app folder.
Then only thing to do is create a folder named Extensions inside app folder and create your UserProviderInterface.php there.
But If I were you, I'd create it under app\Auth\Providers\UserProviderInterface.php
I believe what the page author meant was to create a folder named Extensions and create the provider file under app/Extensions folder. MyApp is just a custom namespace that the author chose, that in default laravel app, it should be App.
Which means, if you create a folder Extensions under app folder, the DummyAuthProvider should then be in the namespace of namespace App\Extensions;

CodeIgniter core library extensions within subfolders

I am curious if it is possible to organize library extensions within subfolders of the libraries directory within codeigniter application.
For example lets say we want to extend the 'Form_validation' library. The default way to extend this core library would be to create a class with the same name prepending 'MY_', and saving it as follows:
/application/libraries/MY_Form_validation.php
Now let's say we want to keep all of our extended libraries we have created within a subfolder called 'extensions' like such:
/application/libraries/extensions/MY_Form_validation.php
When trying the above the extended library is ignored and the default Form_validation class is loaded. Once this happened my first thought was to modify the subclass_prefix within /application/config/config.php to include the 'extensions' directory, however this resulted in an error stating:
Non-existent class: Form_validation
Is it possible to organize your extended libraries in this fashion within codeigniter? Does anyone know how it is done?
If It's have a sub-folder
$this->load->library('extensions/MY_Form_validation');
and after you can access like..
$this->MY_Form_validation->your_function_name();

How to use Amazon s3 as a Codeigniter library?

I created a file called awslib.php and put it in the application/libraries folder. These are the contents of awslib.php:
<?php
class Awslib {
function Awslib()
{
require_once('sdk-1.5.6.2/sdk.class.php');
}
}
Also in the libraries folder is the PHP sdk as a folder named sdk-1.5.6.2.
On my home controller I am loading the library and instantiating the s3 class:
$this->load->library('awslib');
$s3 = new AmazonS3();
When I load my homepage I get this error:
Fatal error: Class 'AmazonS3' not found in /var/www/application/controllers/home.php on line 23
Why isn't it working?
Note: the problem isn't with s3, I can get it to work fine when I store it outside codeigniter and load the demo files that come with the sdk.
I'm assuming you're using the SDK for PHP directly. Most SDKs don't play nicely in CI unless wrapped up.
I highly recommend using the amazon-s3 library (or rather, the spark).

Zend Framework plugin autoloading

I have been trying to write a Controller Plugin which I will be using for user authentication.
I have written the plugin and it should work but I just don't get how to get the plugin loaded... I have read that the Zend Framework has a lot of autoloading possibilities..
My current directory structure:
domains
example.com
Application
configs
controllers
IndexController.php
AuthController.php
ErrorController.php
forms
layouts
scripts
layout.phtml
models
plugins
AuthenticationPlugin.php
views
helpers
scripts
auth
login.phtml
error
error.phtml
index
index.phtml
Bootstrap.php
library
Zend
pubic_html
.htaccess
index.php
Can anyone help me?
Thanks in advance!
Assuming your appnamespace is Application_, then your plugin class should be:
named Application_Plugin_AuthenticationPlugin
stored in the file application/plugins/AuthenticationPlugin.php
registered with the frontcontroller using something like (in application/configs/application.ini):
resources.frontController.plugins.auth = "Application_Plugin_AuthenticationPlugin"
You could create your own library folder with a similar folder structure to Zend's. For instance (assuming your own namespace My_):
library
My
Controller
Plugin
Authentication.php
Authentication.php would contain a class named My_Controller_Plugin_Authentication.
You would then register the namespace in your bootstrap (manual):
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
Failing that, you could use the structure above using the resource autoloader (manual). Zend Framework expects that classes in those folders are namespace prefixed too, so your class name would be Plugin_AuthenticationPlugin.
Add the following line in for example your Bootstrap file:
Zend_Controller_Front::getInstance()->registerPlugin(new AuthenticationPlugin());

Categories