# |
Jul 23rd 2018, 22:06 |
saeideng |
`new yourclass()` |
# |
Jul 23rd 2018, 22:06 |
saeideng |
`use CakePHP_DataDog\yourclass` |
# |
Jul 23rd 2018, 22:05 |
saeideng |
for class |
# |
Jul 23rd 2018, 22:05 |
saeideng |
and for model/ behavior/ ..... |
# |
Jul 23rd 2018, 22:04 |
saeideng |
for controller you must extent main/your controller from plugin controller |
# |
Jul 23rd 2018, 22:03 |
mdotobie |
lets say I have a class, not a model or controller or anything like that, just a class inside the plugin that I want to instantiate |
# |
Jul 23rd 2018, 22:03 |
mdotobie |
But, I can’t figure out how to access plugin resources inside say a main application controller |
# |
Jul 23rd 2018, 22:02 |
mdotobie |
and I can confirm thats working |
# |
Jul 23rd 2018, 22:02 |
saeideng |
just `$this->addPlugin('cakephp-datadog');` |
# |
Jul 23rd 2018, 22:02 |
mdotobie |
so yes I know I can get rid of that |
# |
Jul 23rd 2018, 22:02 |
mdotobie |
that’s how I was originally loading the plugin |
# |
Jul 23rd 2018, 22:02 |
saeideng |
you nno need to this class |
# |
Jul 23rd 2018, 22:02 |
saeideng |
https://github.com/cakephp/debug_kit/blob/master/src/Plugin.php |
# |
Jul 23rd 2018, 22:01 |
saeideng |
so why are u using `use CakePHP_DataDog\Plugin as DataDog;` ?? |
# |
Jul 23rd 2018, 22:00 |
mdotobie |
no I don’t have a class called plugin |
# |
Jul 23rd 2018, 22:00 |
mdotobie |
I was under the impression that I could use Plugin syntax to reference plugin resources |
# |
Jul 23rd 2018, 21:59 |
mdotobie |
now lets say I have a method in the `Plugin.php` file called `info()`. I can only get it to run by declaring a use statement again and then created a new instance |
# |
Jul 23rd 2018, 21:59 |
saeideng |
do you have `Plugin` class ? |
# |
Jul 23rd 2018, 21:58 |
saeideng |
$this->addPlugin('cakephp-datadog'); |
# |
Jul 23rd 2018, 21:58 |
saeideng |
short form |
# |
Jul 23rd 2018, 21:57 |
mdotobie |
and then `$this->addPlugin(DataDog::class);` is in the `bootstrap` method |
# |
Jul 23rd 2018, 21:57 |
mdotobie |
that is in the `Application.php` file |
# |
Jul 23rd 2018, 21:57 |
saeideng |
and for other files/layer , s=you should load Plugin |
# |
Jul 23rd 2018, 21:57 |
mdotobie |
`use CakePHP_DataDog\Plugin as DataDog;` |
# |
Jul 23rd 2018, 21:56 |
saeideng |
you can access to some of that as a file |
# |
Jul 23rd 2018, 21:55 |
mdotobie |
listed like that |
# |
Jul 23rd 2018, 21:55 |
mdotobie |
File uploaded https://cakesf.slack.com/files/U1DEL9TFG/FBVMYPQ9K/-.js / https://slack-files.com/T053DPNCM-FBVMYPQ9K-5215f3dda8 |
# |
Jul 23rd 2018, 21:54 |
mdotobie |
`“autoload”: { “psr-4": { “App\\“: “src”, “CakePHP_DataDog\\“: “plugins/cakephp-datadog/src/” } },` |
# |
Jul 23rd 2018, 21:54 |
saeideng |
check namespace + add to composer.json + do composer dump-autoload |
# |
Jul 23rd 2018, 21:54 |
mdotobie |
and then added to the main composer file as a PS4 entry |
# |
Jul 23rd 2018, 21:54 |
saeideng |
and namespace ? |
# |
Jul 23rd 2018, 21:54 |
mdotobie |
it’s added as a submodule |
# |
Jul 23rd 2018, 21:53 |
mdotobie |
yes it is in the plugins folder @saeideng |
# |
Jul 23rd 2018, 21:53 |
itmpls |
oh that just dumps the already loaded |
# |
Jul 23rd 2018, 21:53 |
itmpls |
hm, why would one need to manually do that, @saeideng? |
# |
Jul 23rd 2018, 21:53 |
saeideng |
`composer dump-autoload` |
# |
Jul 23rd 2018, 21:52 |
mdotobie |
but not in the Packages list of debugkit |
# |
Jul 23rd 2018, 21:52 |
saeideng |
composer dump autoload |
# |
Jul 23rd 2018, 21:51 |
mdotobie |
actually that’s interesting. it shows loaded if I use the `bin/cake plugin loaded` command |
# |
Jul 23rd 2018, 21:51 |
saeideng |
is it in ` /plugins` folder ? |
# |
Jul 23rd 2018, 21:49 |
itmpls |
thanks @saeideng |