I have a cake php project on the root of the server, I need to put some php files that should work individually.How I should do?
If you want to access your files eg with browser, you have at least two options here:
Standalone Scripts run from the CLI
If you want to know 'how' to do this in cake you should really consider using a shell if you are running from the command line.
Shells solve the problems of one off scripts that need to be run from the command line.
Files Requested via the Browser
If you are interested in reaching the file from the browser, I would advise you add the action to one of your controllers. Even if you don't want to rewrite the script into cake, you should still run the request through a controller so eventually, you will be able to port the script into cake. Or leverage any authentication or testing if needed.
If you have a standalone script that you want to load, make it into a library.
App\Lib\MyUtility.php
<?php
namespace App\Lib;
class MyUtility
{
public function doThings()
{
echo "Hey I am doing things";
}
}
App\Controller\UtilitiesController.php
<?php
namespace App\Controller;
use App\Controller\AppController;
use App\Lib\MyUtility;
class UtilitiesController extends AppController
{
public function doThings()
{
(new MyUtility())->doThings();
// You can exit here or actually give some feedback to the browser if needed
exit;
}
}