Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /
- * @component to write sample script which will pass to backend jobs
- *
- */
- App::uses('Component', 'Controller');
- class BackgroundScriptComponent extends Component {
- public function crawllUrls($crawling) { // Passing 200 urls to crawl
- for ($i = 0; $i < $Counter; $i++) {
- /*
- Internal code which is running perfect using browser hit
- */
- }
- }
- }
- /* @component to write sample script which will pass to backend jobs */
- Controller:
- class ScriptController extends AppController {
- public $components = array('BackgroundScript');
- public function CreateBackendProcess() {
- $this->layout = false;
- $this->autoRender = false;
- $arrOfUrls = array('500 url there in this array');
- //echo $this->BackgroundScript->crawllUrls($crawling); // This line having Component method call. I do not want to call this as same as.. It should call from CLI
- $cmd = ""; //what should come in this $cmd to calls BackgroundScript's crawllUrls() method component which will pass to exec()
- exec($cmd, $pid);
- echo "<br />Script Running with process id " . json_encode($pid); //I will save this PS ID to database
- exit;
- }
- }
Add Comment
Please, Sign In to add comment