Codeigniter and Doctrine 500 internal error - php

I've tried to combine Doctrine with Codeigniter and I'm almost there, I think.
The version of Codeigniter is 2.0.2 and from Doctrine is 2.0.0.
The problem is now that I get an 500 internal server error using the flush() method of Doctrine.
I am following a tutorial (http://wildlyinaccurate.com/integrating-doctrine-2-with-codeigniter-2/) to install doctrine with codeigniter. But at the last step it just fails and I don't know why.
This is my code in my controller:
$app = new models\application;
$app->setName("Test applicatie");
$app->setGuid();
$this->doctrine->em->persist($app);
$this->doctrine->em->flush(); //If I comment this out, it loads the view...
$this->load->view('welcome_message');
When I comment out the flush method it loads the view.
Thanks in advance.

Well, since $this->doctrine->em->flush(); is what actually does the write to the DB, Make sure you have the required MySQL user rights to do the DB action.
Write the query directly in MySQL and make sure that the error isn't thrown there.

Make sure to put some content in fields that cannot be null.

Related

No hint path defined for [pagination]. Laravel 5.3

I'm receiving this error on pagination, and reset password post request on Laravel 5.3. Trying to figure out what's causing since I can see that error happens on FileViewFinder.php line 112, which contains:
if (! isset($this->hints[$segments[0]])) {
throw new InvalidArgumentException("No hint path defined for [{$segments[0]}].");
}
This code is part of the getNamespaceSegment($name) method, which gets the segment of a template with a named path. Thank you in advance!
I figured out, what was happening. Basically the message says FileViewFinder cannot find the related templates that are required when pagination function is called:
$paginator->links();
So the solution is to first make sure the files are published by running:
php artisan vendor:publish --tag=laravel-pagination
And then update path to the pagination templates located in resources/views/vendor/pagination:
$paginator->links('vendor.pagination.default')
You may have error into your blade file, define the default pagination file
$paginator -> links('vendor.pagination.default')
you can set it manually
if you have your blades views in ...views/pagination, that is how you can specify it:
app('pagination')->addNamespace('mail', resource_path('views') . '/pagination');

APYDataGridBundle error

After I installed this bundle and I'm using in controller follow code:
use APY\DataGridBundle\Grid\Source\Vector;
......
$source = new Vector($deliveries);
$grid = $this->get('grid');
Row with $source.... works normal. I tried var_dump($source) and saw the right data. But second row gave me next error:
You have requested a non-existent service "request". Did you mean one of these: "router.request_context", "request_stack", "monolog.logger.request", "validate_request_listener", "data_collector.request"?
What need I to change?
I found the answer. For Symfony > 2.8 need use this bundle
https://github.com/artscorestudio/APYDataGridBundle/blob/master/Resources/doc/index.md

Call to undefined method ActiveRecord\Config::initialise() composer

Hey everyone I'm following a tutorial on Composer, I've installed ActiveRecord and I'm trying to create a database model. Whenever I load the page though I get this error: Call to undefined method ActiveRecord\Config::initialise()
Here's my setup file in index.php
require_once "vendor/php-activerecord/php-activerecord/ActiveRecord.php";
ActiveRecord\Config::initialise(function($cfg) {
//setting up a model (which is the representation of a table)
$cfg->set_model_directory('models');
$cfg->set_connections(array(
'development' => 'mysql://root:tutsplus#localhost/blog'
));
});
$posts = Post::all();
print_r($posts);
?>
And here's where I declare Post
class Post extends ActiveRecord\Model{}
I really cannot find the reason this isn't working, I actually did this instead to see if manually creating a new Post instance would fix the initialisation problem but it didn't, it had exactly the same error:
$post_class = new Post;
$posts = $post_class->all();
print_r($posts);
I'm really stumped on this one, I've usually managed to find something that fixes my problem on here but this is just nope. There is literally no difference to the tutorial code that I can see and I've checked it loads of times. Any help would be greatly appreciated.
(edit: the duplicate php-activerecord folders at the top isn't a code problem, the folder is actually duplicated and I haven't got round to moving the contents yet)
Point one: When using Composer, you are supposed to only include "vendor/autoload.php", and nothing else. Composer does the rest of autoloading for you.
Point two: It is called initialize with a Z, not S. You might simply have misspelled that method name.

Yii - CHttpRequesterror while functional unittesting in module

When I'm trying to execute a functional unittest of a module within my Yii code, I keep receiving the following error:
CException: CHttpRequest is unable to determine the request URI.
At first, I though it was because it couldn't find the module. However, If I change the url to a wrong one, I get a correct error,s tating it couldn't find the view.
This is how my testing code looks like
public function testViewControllerModule()
{
ob_start();
Yii::app()->runController('module/controller/view');
}
Any ideas on what I might be missing?
bool.devs answer works so far.
This blog post explains the origin of the exception pretty well:
http://mattmccormick.ca/2012/09/14/unit-testing-url-routes-in-yii-framework/
In my case, I generalized the solution and have set the following variables in /www/protected/tests/bootstrap.php:
...
$_SERVER['SCRIPT_FILENAME'] = 'index-test.php';
$_SERVER['SCRIPT_NAME'] = '/index-test.php';
$_SERVER['REQUEST_URI'] = 'index-test.php';
Yii::createWebApplication($config);
Consider using 'index-test.php' instead of 'index.php' because it contains the config 'test.php' which is responsible for fixtures and maybe other test relevated configurations.
If someone has better suggestions feel free to comment :)
Kind regards
I think it's because you haven't set any server variables, i.e $_SERVER and you might be doing something like this in your controller:
Yii::app()->request ....
So before you run your test, make sure you use a fixture for the server variables also. I think this should suffice for now:
$_SERVER=array(
'REQUEST_URI'=>'index.php', // the other fields should follow
);
However to run functional tests i would recommend using SeleniumRC, you won't have to do these workarounds then, and can simulate user clicks also, i think.
Read the initial guide to Functional Testing , read the selenium rc phpunit guide, and also the CWebTestCase documentation.
Notes: You might still have to use fixtures for some variables, and i don't have much experience in testing(which is bad), so i'm not very sure if i am completely correct about selenium.

CodeIgniter: Can't Get My New Controller/View To Show

I am learning how to use codeIgniter as my php framework. I am reading through the documentation and watching the intro video and just generally following along with the first tutorial, but it's not working for me.
I have created a controller called "test.php" and a view called "test_view". The controller for this class is exactly like "welcome.php" and the view file just has some static html. However, when I go to index.php/test I get a 404 error.
I have also tried manipulating the original welcome files so that instead of calling a view it just echos "testing", yet I still see the original welcome message! I've tried clearing my browsing cash and refreshing, but to no avail.
Any suggestions? Thanks.
Edit: Here's the code for controllers/test.php
<?php
class Test extends Controller {
//Just trying to get it to echo test
public function index()
{
echo "test";
//$this->load->view('test_view');
}
}
?>
Try looking at this page in the documentation - this might solve your problem.
This basically means you should try typing index.php?/test/ instead (notice the question-mark).
First of all, check the above link. Might be useful.
If not, then...
Try changing the default controller in the config file ('routes.php') to something else (probably, to 'test'), then try loading index.php. Just to test whether the whole system works (or not).
Check whether mod_rewrite is loaded (in your server .conf-file, if you're using Apache).
Try using the latest build of the framework. AFAIK, the name of the controller class for now is "CI_Controller".
Finally, try removing the word 'public' before the declaration of the function. AFAIR, CI enable you to make private functions in controllers just by using prefix (which is set in the config file) at the beginning of the name of the function (thus making all the other functions public).
But most certainly the problem is with the mod_rewrite. If not, try debugging with die('Page found'); instead of echo - this will allow you to track possible redirects on the page.

Categories