codeignither HMVC version 3.0.6 view not loading - codeigniter-3

The follwing below is an controller for an template i am making in codeignither HMVC. I am trying to load this template module in my task modules but for some reason it wont load in the template modules but the data loads in my task controller.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class templates extends MX_Controller
{
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* #see https://codeigniter.com/user_guide/general/urls.html
*/
public function one_col($data)
{
$this->load->view('one_col',$data);
}
public function two_col($data)
{
$this->load->view('two_col',$data);
}
public function admin($data)
{
$this->load->view('admin', $data);
}
public function index()
{
echo "Hello world";
}
}
this code below is my task controller and it works fine when i run it in the link http://localhost:81/hmvc/index.php/tasks however when i try to run the template view "two_col" http://localhost:81/hmvc/index.php/templates/two_col
using this code in the template
<?php $this->load->view($module.'/'.$view_file); ?>
i get this error :
task module controller below
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class tasks extends MX_Controller
{
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* #see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->model('mdl_tasks');
$data['query'] = $this->mdl_tasks->get('priority');
#$this->load->view('display', $data);
$data['view_file'] = "display";
$data['module'] = "tasks";
echo Modules::run('templates/two_col', $data);
#$this->load->module('templates');
#$this->templates->two_col($data);
}
}

echo Modules::run('templates/two_col', $data);
#$this->load->module('templates');
I'm pretty sure replacement these codes together will work.
Because php is an interpreted programming language. PHP loads every line one by one if deteced an error for ex. on 5Th line it doesnt compile the rest of lines. More information for interpreted lang. and also in your code you implementing the lib function before loading lib

Related

SuiteCRM v7.10.29 Custom API v4.1

I am creating a custom API for SuiteCRM. When I attempt to run the new API from {CRM Home}/custom/service/v4_1_custom I receive an 'HTTP ERROR 500'. There are not errors in the error_log file or the SuiteCRM.log file.
I have followed the method in the following two url's
https://fayebsg.com/2013/05/extending-the-sugarcrm-api-updating-dropdowns/
https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.0/Integration/Web_Services/Legacy_API/Extending_Web_Services/
registry.php
<?php
require_once('service/v4_1/registry.php');
class registry_v4_1_custom extends registry_v4_1
{
protected function registerFunction()
{
parent::registerFunction();
$this->serviceClass->registerFunction('test', array(), array());
}
}
SugarWebServicesImplv4_1_custom.php
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('service/v4_1/SugarWebServiceImplv4_1.php');
class SugarWebServiceImplv4_1_custom extends SugarWebServiceImplv4_1
{
/**
* #return string
*/
public function test()
{
LoggerManager::getLogger()->warn('SugerWebServiceImplv4_1_custom test()');
return ("Test Worked");
} // test
} // SugarWebServiceImplv4_1_custom
I found the answer to this issue.
In the file {SuiteCRM}/include/entryPoint.php there are many files that are included thru require_once. In this list of require_once files, there were 4 files that were set as require not require_once. These were classes and therefore could not be included a second time. I changed these to require_once and the HTTP Error 500 went away and the custom APIs started working.

Why Symfony4 annotations not work in my mac?

I installed Symfony4 using the following steps.
step1: composer create-project "Symfony/skeleton:^4.0” symfony4
step2: git status
step3: git add.
step4: git commit
step5: composer require annotations
step6: create a controller named ArticleController
<?php
namespace App\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Response;
class ArticleController
{
/**
* #Route("/")
*/
public function indexAction()
{
return new Response('OMG! My first page already! Wooooo!');
}
/**
* #Route("/{id}", requirements={"id" = "\d+"}, defaults={"id" = 1})
*/
public function showAction($id)
{
echo 123;die;
}
/**
* #Route("/news/{$slug}")
* #Method({"GET", "POST"})
*/
public function news($slug)
{
return new Response(sprintf('Today new is "%s"', $slug));
}
}
Step7: access http://127.0.0.1:8000
You can view 'OMG! My first page already! Wooooo!'.
But http://127.0.0.1:8000/123 and http://127.0.0.1:8000/news/test do not work. Who can tell me why? And please help me to fix it.
Just find the solution.
composer require symfony/apache-pack
It will automatically generate .htaccess.
the right namespace is :
use Symfony\Component\Routing\Annotation\Route;
thanks

Make Laravel use database Queue instead of sync

I need help with Laravel Queues if someone can help me further, i have done these steps till now
changed the QUEUE DRIVER in .env file to database
created migrations for queue table jobs and failed-jobs
php artisan queue:table
php artisan queue:failed-table
and i have run php artisan migrate
created a new Job
php artisan make:job SendNewArticleNotification
Update:
Ok i have created a route /queue
Route::get('/queue', function () {
dispatch(new \App\Jobs\SendNewArticleNotification);
});
and in my Job SendNewArticleNotification i have this
<?php
namespace App\Jobs;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendNewArticleNotification implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* #return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* #return void
*/
public function handle()
{
$users = User::all();
$article = \App\Article::first();
foreach ($users as $user) {
$user->notify(new \App\Notifications\Published($article));
}
}
}
And when i hit my /queue route the emails are beeing sent but they are not using the database table....it takes more than 30 seconds to send 50 mails...
UPDATE
Ok i finally figured it out that dispatch() needs to be inside of a controller method because the controller has the trait dispatches jobs....and now my jobs are in queue in DB table jobs....so how do i trigger them behind the scenes?
Put your dispatch in your controller method and then run
php artisan queue:work

Typo3 - Extbase CommandController for scheduler task

i ve created an empty extbase/fluid extension and added an ImportCommandController for a scheduler task. For some reason i am not able to load that task in my scheduler. Please note that i want to realise my task via CommandController (http://wiki.typo3.org/CommandController_In_Scheduler_Task) and NOT via \TYPO3\CMS\Scheduler\Task\AbstractTask.
ext_localconf.php
<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'VENDORx\\Sched\\Command\\ImportCommandController';
Classes/Command/ImportCommandController.php
<?php
namespace VENDORx\Sched\Command;
/**
*
*
* #package Sched
* #license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*
*/
class ImportCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {
public function importCommand($commandIdentifier= NULL) {
echo 'command run';
}
}
?>
any idea whats missing??
As Jost already mentioned you neet proper Annotations:
/**
* #param integer $commandIdentifier
*/
public function importCommand($commandIdentifier = NULL) {
$this->outputLine('command run');
}
Select "Extbase-CommandController-Task" in dropdown
You'll get another select field on the bottom where you can find your "ImportCommand" select and save

Unit Testing with PHPUnit & Doctrine2: Autoloading Failed

I am getting this error
D:\Projects\Tickle\tests>phpunit
PHPUnit 3.5.5 by Sebastian Bergmann.
..........ok1
Fatal error: Doctrine\Common\ClassLoader::loadClass(): Failed opening required 'D:\Projects\Tickle\Application\Models\Ap
plication\Models\User.php' (include_path='D:\Projects\Tickle\application/../library;D:\Projects\Tickle\application;D:\Pr
ojects\Tickle\library;D:\ResourceLibrary\Frameworks\PHPFrameworks;C:\Program Files (x86)\PHP\pear;.;c:\php\includes') in
D:\ResourceLibrary\Frameworks\PHPFrameworks\Doctrine\Common\ClassLoader.php on line 148
Notice its repetition "D:\Projects\Tickle\Application\Models\Application\Models\User.php" of Application\Models. I narrowed it down to 1 function of my unit tests with the help of some echo statements
protected function isAllowed($userId, $taskId, $privilege) {
$user = $this->em->find('Application\Models\User', $userId);
echo 'ok1'; // this gets printed
$task = $this->em->find('Application\Models\Task', $taskId); // this seem to be the cause of the problem
echo 'ok2'; // this doesn't get printed
return $this->acl->isAllowed($user, $task, $privilege);
}
The full class http://pastebin.com/rJungFvP
So I tried looking of something in the Tasks class that uses User ... the only thing that might use the User class are
/**
* #ManyToOne(targetEntity="User", inversedBy="ownedTasks")
*/
protected $owner;
/**
* #ManyToOne(targetEntity="User", inversedBy="assignedTasks")
*/
protected $assigned;
apart from that, I don't see use of any Users. full class http://pastebin.com/wDPXUPSV.
What did I do wrong?
The problem was actually found in the TodoList class ... I had something like
public function setProject(Application\Models\Project $project) {
...
}
when I should be using something like
public function setProject(Project $project) {
$this->project = $project;
}
instead