UPDATE: I managed to resolve the issue by completely removing the vendor directory, and re-running the composer install command. I still don't know what was the actual cause of this beahviour, but at least it's working now.
I've been tasked to troubleshoot and improve an application written in Laravel.
Since I almost always worked in Codeigniter, my knowledge of Laravel boils down to "I know what it is and where to download it from" :)
So, the application fails with the the following error:
PHP Warning: Uncaught ErrorException: require(\Repos\PermissionRepo.php): failed to open stream: No such file or directory in \wwwroot\app\Repos\PermissionRepo.php:5
the PermissionRepo file looks like this:
2: namespace Wckphma\Repos;
3:
4: use Illuminate\Support\Facades\Auth;
5: use Wckphma\User;
the seemingly missing Wckphma\User declaration file does exist, and the beginning of the file looks like this:
namespace Wckphma;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Wckphma\Repos\GroupRepo;
use Wckphma\Repos\PermissionRepo;
class User extends Authenticatable
{
****
It cannot be the file permissions, as in pure desperation I gave all the user read/write permissions to all files throughout.
Any ideas, what this might be?
Related
I have a PHP file located at holiday/app/Console/Commands/myCommand.php with:
namespace Holiday\Console\Commands;
$bob = file_get_contents('Storage/data/BE.json');
and it works.
However in holiday/app/Http/Controllers/holidayController.php I have:
namespace Holiday\Http\Controllers;
$bob = file_get_contents('Storage/data/BE.json');
but I get
file_get_contents(Holiday/Storage/data/BE.json): failed to open stream:
No such file or directory
Does anybody know why this is?
You should always use helpers to get correct path. Here, use storage_path() helper. For instance:
file_get_contents(storage_path('data/BE.json'))
This will create correct path to the laravel_project/storage/data/BE.json file.
I was able to create the directory, but when I tried to create the namespace App\Http\Controllers\Orders; PHP Storm was showing errors. I could namespace with any other directory name that I tried within \Controllers except for \Orders.
Any ideas why this is?
I uploaded the paypal php sdk to my codeigniter app inside the libraries/paypal folder.
In the same folder I create a paypal.php file and inside it I insert this code:
<?php
require __DIR__ . '/common.php';
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
class Paypal{
function createPayment(){
$payer = new Payer();
$payer->setPaymentMethod("paypal");
//....
}
}
but when I call this function in my controller I get this error:
Fatal error: Class 'PayPal\Api\Payer' not found in '....'
I don't understand why instead common.php is imported correctly.
In my app I also have the Facebook sdk and I created the same structure to use it and it works
Best way is to follow these steps.
Download the SDK using composer.
Upload the vendor directory into codeIgniter Application root.
Then in the index.php file put this line
include "./vendor/autoload.php";
Now you can access the Paypal SDK and its dependent libraries easily.
Using Magento in admin, when I click the configuration tab, I get the following error:
"Fatal error: Class 'Magestore_Magenotification_Helper_Data' not found in."
Does anyone know why this would happen and how to fix it?
Normally this error occurs only if your Helper data is missing. Check your Data.php file at your_code_pool/Magestore/Magenotification/Helper. If that file does not exist, check your downloaded module or contact #Magestore if you install this module by Magento connect or create Data.php file with following code: (This may fix the above error only)
<?php
class Magestore_Magenotification_Helper_Data extends Mage_Core_Helper_Abstract
{
}
You need to disable the module. Go to app/etc/modules in your codebase and open file Magestore_Magenotification.xml and change the <active> node to false. Clear magento cache and reload the page.
Please check the config.xml of the module and also verify the namespace of the module which must match with the module name space under app/etc/modulename_namespace.xml.
I had this error because I was on PHP 7.1 and not 5.6
I get phpunit and install it as this link using the simplest way for test purposes.
I just download the phpunit.phar file, chmod & rename & move to /usr/local/bin Then, I run phpunit --version, its ok.
PHPUnit 3.7.27 by Sebastian Bergmann
I write a simple test
public function testSomething(){
$this -> assertTrue(true)
}
Then I go into the source file folder, phpunit --colors Test
It works. So, I decide write a complex demo.
My project folder structure is like this.
Project Name
--> app
--> api
--> tests
Now I write a simple class in app/api/FlyApi.php
<?php
class FlyApi {
public function makeFly(){
//do something else
}
}
Then I write another test class for FlyApi.php
<?php
class FlyApiTest extends PHPUnit_Framework_TestCase {
public function testFly(){
//new a FlyApi
$flyApi = new FlyApi();
//do something
}
}
At this line $flyApi = new FlyApi() I got the error.
PHP Fatal error: Class 'FlyApi' not found in /home/kevin/Workspace/fly/app/api/FlyApi.php on line 23
Yes, this line $flyApi = new FlyApi()
You didn't load the definition of your FlyApi class.
This solution is Laravel specific:
You should be extending TestCase rather than PHPUnit_Framework_TestCase.
Try adding your /api/ folder into your ClassLoader at app\start\global.php.
You will find this section:
ClassLoader::addDirectories(array(
app_path().'/commands',
app_path().'/controllers',
...
app_path().'/api/
));
Are you using Laravel's phpunit.xml file? It includes Laravel's (and Composer's) autoload.php file which lets you use all your autoloaded classes within it.
Finally, what's the whole error? It should (hopefully) tell you what class it's trying to load (which will give you clues if the namespace is wrong or something).