Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling CakePHP functions out of controller and app folder

Tags:

php

soap

cakephp

I have a CakePHP project with this structure:

myrootapp
|__ app
   |__webroot
      |__soap.php

I'm calling my webservice in this soap.php, but I am calling some cakephp controller inside of my webservices functions like this link.

But the App::import causes an error in my application because the App::import is not imported into soap.php.

How I can import and use the CakePHP function in my soap.php page inside the webroot folder? I want to use App::cakephpFunctions to import the controllers.

** UPDATE**

I'm calling App:import inside the soap.php in webroot. I wanna solve this and call my controllers in this file.

PHP Fatal error:  Class 'App' not found in 

Thanks.

like image 963
ErasmoOliveira Avatar asked Jan 01 '26 04:01

ErasmoOliveira


1 Answers

In order to use stuff from the framework, you need to load/initialize it first. You can do that by including the CakePHP bootstrap file into your soap.php file:

require_once('/path/to/your/cakephp/lib/Cake/bootstrap.php');

That will initialize the framework, including the App class.

like image 155
Oldskool Avatar answered Jan 03 '26 16:01

Oldskool



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!