5.7 how do you include and instantiate a custom class (application/src). as in not a core classs (concrete/src)
Permalink 1 user found helpful
I have an instagram class located in application/src/instagram.php
The name of the class is Instagram
Im trying to use this class inside my theme....
Example:
I modeled this after an example on this page
http://www.concrete5.org/documentation/developers/5.7/environment/a...
use \application\Core\Instagram;
$instagram = new Instagram();
var_dump($instagram);exit;
Im getting the error:
Class 'application\Core\Instagram' not found
what am I doing wrong?
The name of the class is Instagram
Im trying to use this class inside my theme....
Example:
I modeled this after an example on this page
http://www.concrete5.org/documentation/developers/5.7/environment/a...
use \application\Core\Instagram;
$instagram = new Instagram();
var_dump($instagram);exit;
Im getting the error:
Class 'application\Core\Instagram' not found
what am I doing wrong?
I have added in the namespace call in the top of my instagram class as you suggested and im now getting an error:
syntax error, unexpected '/', expecting T_STRING or T_NS_SEPARATOR or '{'
also I have attached a screenshot
so now i have...
instagram class
file trying to use the instagram class:
syntax error, unexpected '/', expecting T_STRING or T_NS_SEPARATOR or '{'
also I have attached a screenshot
so now i have...
instagram class
<?php namespace /Application/Src; class Instagram {}?>
file trying to use the instagram class:
<?php use \Application\Src\Instagram; $instagram = new Instagram(); var_dump($instagram);exit; ?>
sorry, I mispoke
namespace should be Application\Src;
backslashes all the way, and you shouldn't need it right before Application
namespace should be Application\Src;
backslashes all the way, and you shouldn't need it right before Application
Hi there
Similar problem here. My class file is located at
using 5.7.4
Trying to use it in a single page like so:
or
Error: What am I missing?
Similar problem here. My class file is located at
/application/src/paypal/paypal.php
using 5.7.4
namespace Application\Src\Paypal; class Paypal { }
Trying to use it in a single page like so:
$paypal = new Application\Src\Paypal\Paypal();
$paypal = new \Application\Src\Paypal\Paypal();
Error:
Class 'Application\Src\Paypal\Paypal' not found
in the file path, everything after /src/ needs the same capitalisation as the namespace.
Thank you! That was it. And if I had a look at /concrete/src I should have seen this.....
awesome, that worked thanks a bunch!
spent a few hours on that..... glad to be getting past it.
spent a few hours on that..... glad to be getting past it.
Just a heads up folks - this has changed in version 8. The files will still live in application/src, but the namespacing has changed. See:https://documentation.concrete5.org/developers/extending-concrete5-w...
is that the case? If so, you call the use in Upper camelcase such as