Get code of Pro PHP MVC book by Chris Pitt - php

I have read the book till chapter 14: Registration and login but whenever I try to run the application i get the following error
I have uploaded the Github Repo
If anyone who has the code for the book please share
( ! ) Strict standards: Non-static method Framework\Core::initialize()
should not be called statically in
C:\wamp\www\SwiftMVC\public\index.php on line 8
( ! ) Notice: Undefined variable: this in
C:\wamp\www\SwiftMVC\framework\core.php on line 14
( ! ) Fatal error: Uncaught exception 'LogicException' with message
'Passed array does not specify an existing static method (first array
member is not a valid class name or object)' in
C:\wamp\www\SwiftMVC\framework\core.php on line 14 ( ! )
LogicException: Passed array does not specify an existing static
method (first array member is not a valid class name or object) in
C:\wamp\www\SwiftMVC\framework\core.php on line 14

The publisher only offers the source code separated in each chapter.
In case you don't already know it can be found under ...
http://www.apress.com/9781430241645
Open the tab 'Source Code/Downloads'.

I have read the book Pro PHP MVC by Chris Pitt, there are 2 things i am not sure about-
1. The Core class and how autoloading of classes is done.
2. ArrayMethods::last isn't defined anywhere, my guess is that it is simply returning the last element but not sure of it.

Related

Fatal error: Uncaught Error: Class 'INFOCUS_THEME\Inc\Menus' not found

I am trying to follow a WordPress tutorial by Imran Sayed - Codeytek Academy (https://www.youtube.com/watch?v=lNtw4yxEydM&list=PLD8nQCAhR3tT3ehpyOpoYeUj3KHDEVK9h) to allow wordpress to build a menu and then inject into the html. I have followed the turorials 22, 23 and 24 (from the playlist) trying to use this in my own project.
I have copied the code and folder/file structure and added in the class, helpers, singletons and autoloaders. BUT everytime I try and run the code i get
Fatal error: Uncaught Error: Class 'INFOCUS_THEME\Inc\Menus' not found in /home/will/Local Sites/karenkeyinfocus/app/public/wp-content/themes/infocus/template-parts/header/nav.php on line 13
Error: Class 'INFOCUS_THEME\Inc\Menus' not found in /home/will/Local Sites/karenkeyinfocus/app/public/wp-content/themes/infocus/template-parts/header/nav.php on line 13
I have changed the text domain from aquila to infocus as thats whats in my project in all the locations. BUT i am completly stuck and can't work out why my code is not running.
Think this is the code thats causing the problems as it can't find the class 'INFOCUS_THEME\Inc\Menus'
<?php
$menu_class = \INFOCUS_THEME\Inc\Menus::get_instance();
$header_menu_id = $menu_class->get_menu_id( 'infocus-header-menu' );
$header_menus = wp_get_nav_menu_items( $header_menu_id );
?>
I have uploaded it to my github account and post the link here, as I thought that is the best way.
https://github.com/wkey1980/infocus
When declaring a variable as a class you must use 'new' to initiate the class.
$menu_class = new \INFOCUS_THEME\Inc\Menus();
//and then you can do
$menu_instance = $menu_class->get_instance();

Jomsocial error - Notice: JFactory::getUser(): The script tried to execute a method or access a property of an incomplete object

Im getting 2 errors. I saw that Jomsocial had the problem with their own site and fixed it but never posted how. Happens when you go to post an update in jomsocial and it locks up. You refresh the page and get
Error
Sorry, User ID not found.
with the following errors. Then you go login and check the profile and the update was posted fine.
Notice: JFactory::getUser(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CUser" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxxxx/public_html/libraries/joomla/factory.php on line 244
Notice: CUser::CUser(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CUser" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxxx/public_html/components/com_community/libraries/user.php on line 52
What version of JomSocial do you use? This issue shouldn't happen

Changed a table name in MySql => error in symfony code

I changed a table name from 'match' to 'matchGame'. Then I edited all of my code so that matchGame was used everywhere. I then used the commands doctrine:import and generate:entities to update all the things for the database. However if I run my program now I get following error:
[Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 1 passed to Login\LoginBundle\Entity\Tactic
s::setMatchMatchid() must be an instance of Login\LoginBundle\Entity\Match,
instance of Login\LoginBundle\Entity\Matchgame given, called in C:\wamp\ww
w\SocProNetbeans\src\Login\LoginBundle\Command\CreateSeasonCommand.php on l
ine 73 and defined in C:\wamp\www\SocProNetbeans\src\Login\LoginBundle\Enti
ty\Tactics.php line 632
What adjustment do I need to do to change this?
It looks like you've not changed the name of your Match entity class.

Fatal error: Call to a member function in product.php

I am new to opencart, so please help me.
I am using opencart version 1.5.6, now whenever I edit and delete the product it shows me
Fatal error: Call to a member function productUpdateListen() on a non-object in /home/crazepur/public_html/admin/controller/catalog/product.php on line 78
and
Fatal error: Call to a member function deleteProduct() on a non-object in /home/crazepur/public_html/admin/controller/catalog/product.php on line 133 respectively.
Although it edit and delete the product.
Please help me how to fix it.
Code in Line 78 $this->openbay->productUpdateListen($this->request->get['product_id'], $this->request->post);
And code in line 133 $this->openbay->deleteProduct($product_id);
This means $this->openbay is not an object which contains function productUpdateListen() & deleteProduct(), probably it's NULL or false in some cases (nothing found) due to it's not accessible. Out of scope.
Try
var_dump($this->openbay);
Check the O/P
it's simple and the error-message says it all: your $this->openbay doesn't have those methods (productUpdateListen() and deleteProduct()) - most likely it isn't an object at all.
please debug your code since it's impossible to say what's going wrong wich so little information. to start, do a var_dump($this->openbay); right before the function-calls and check the output.

Error with sphinx php api class used in symfony2 as a service

I use sphinx php api as a service in a symfony2 project when I want to search a term in an index i got this warning
Warning: Invalid argument supplied for foreach() in /var/www/domain.com/Symfony2/src/project/myBundle/services/SphinxClient.php line 997
this is the line 997
foreach ( $this->_weights as $weight )
so I added a test befor foreach() like this if(!empty($this->_weights))
the same error appaires in each foreach so I added the same test.
then an other error appaires
Notice: Undefined property: prject\MyBundle\services\SphinxClient::$_socket in in /var/www/domain.com/Symfony2/src/project/myBundle/services/SphinxClient.php line 563
I was loking for the problem origin for hours.
thanks for your help in advance.
In sphinxapi.php file used old constructor.
Delete string ( near 430 )
function SphinxClient()
and write:
public function __construct()
and all very well.
Don't forget to set namespace in file (I renamed sphinxapi.php to SphinxClient.php) and write in begin it:
namespace Acme\MyBundle\Sphinx;
Your path may be something else.
Without seeing the source of the file, not a lot can do to help.
IN the standard sphinxapi.php class that comes with sphinx the varaiables are all class variables, so $this->_weigths is an array. Maybe that was missed when it was poted to Symfony

Categories