CodeIgniter 3 - library replacement - codeigniter

Tried to implement Monolog into a CodeIgniter 3 base installation, and implemented as per the instructions here: https://github.com/stevethomas/codeigniter-monolog, but for some reason CI 3 does not replace the built-in system CI_Log library. I have done the following:
Installed Monolog via Composer.
Copied monolog.php and Log.php as per instructions to config and libraries respectively.
Added the Composer autoload instruction to my CI index.php file; the autoloader is being called, but the library is not initialized.
Expected result: Use Monolog instead of native CI logging.
Result observed: CI used built in CI logging.
What am I missing?

See http://www.codeigniter.com/user_guide/general/core_classes.html#replacing-core-classes
You must put it in application/core directory.
And about Composer autoloader. CI 3 has its config $config['composer_autoload'].
See http://www.codeigniter.com/user_guide/general/autoloader.html

Related

Can't find the config/packages/api_platform.yaml on Symfony 6

After installing the API platform on my Symfony 6.2 project using the composer command composer require API
I can't find the api_platform.yaml file in config/packages folders, the only file related to API-PLATFORM I found is on the routes directory
Is this a new update? Or should I add it in a certain way?
Go to
config/packages/
Create
api_platform.yaml
Add your configuration
api_platform:
title: 'MY API'
Restart the Symfony Dev Server
symfony server:stop
symfony server:start
Check https://localhost:8000/api/docs to see the results.

Unable to find PHPUnit\Framework\Constraint\Constraint in Laravel BrowserKit package after upgrade to 5.4

I'm upgrading an old Laravel personal project from 5.2 to 5.4. The upgrade to 5.3 seems to have gone OK, but now I'm moving to 5.4 I've run into an issue.
The project used the old testing layer so I've installed the BrowserKit testing package to maintain backward compatibility. I also created the following base test case for the Browserkit tests:
<?php
namespace Tests;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class BrowserKitTestCase extends BaseTestCase
{
use CreatesApplication;
public $baseUrl = 'http://localhost';
}
The tests for the models, which use the normal test case, work fine, but when I run any of the tests that use the BrowserKit test case, I see the following error message:
PHP Fatal error: Class 'PHPUnit\Framework\Constraint\Constraint' not found in /home/matthew/Projects/myproject/vendor/laravel/browser-kit-testing/src/Constraints/PageConstraint.php on line 10
PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php:895
Stack trace:
#0 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(735): Illuminate\Container\Container->notInstantiable('Illuminate\\Cont...')
#1 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(608): Illuminate\Container\Container->build('Illuminate\\Cont...')
#2 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php(575): Illuminate\Container\Container->resolve('Illuminate\\Cont...')
#3 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(728): Illuminate\Container\Container->make('Illuminate\\Cont...')
#4 /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExce in /home/matthew/Projects/myproject/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 895
Google hasn't been much use with this and the error message is not terribly illuminating. It seems to be something to do with the namespace because the class PHPUnit\Framework\Constraint\Constraint doesn't appear to exist, but I'm not sure how to resolve the issue. I've upgraded the version of PHPUnit to 5.7 as necessary, but that doesn't resolve the issue. Can anyone suggest what the issue might be?
EDIT: Just thought to try downgrading the version to 1.0 and that seems to solve the problem for now, so maybe version 2.0 is intended to work with PHPUnit 6? Still, hopefully this post will help someone out in future.
I ran into this today also.
Instead of downgrading laravel/browser-kit-testing from ~2.0 to ~1.0, I upgraded "phpunit/phpunit" from 5.7 to ~6.0 and that fixed the problem.
I agree that it is related to the PHPUnit namespaces. There is a commit to laravel/browser-kit-testing from May 25 with a title of "Use PHPUnit 6.0 namespaced classes."
Downgrading laravel/browser-kit-testing to 1.0 seemed to resolve the issue, so I'm guessing it's something to do with the namespaces for PHPUnit.
I think you need to instruct your test runner to use the bootstrap autoloader file containing PHPUnit class aliases.
try
phpunit --bootstrap bootstrap/autoload_test.php
If you are using a phpunit.xml configuration file, make sure your phpunit tag contains bootstrap="bootstrap/autoload_test.php" amongst your other set options, like the following:
<phpunit bootstrap="bootstrap/autoload_test.php">
You can instruct your test runner to read your phpunit.xml like so:
phpunit --configuration phpunit.xml

Auth guard driver [api] is not defined?

I use this library jwt-auth-guard in Laravel 5.3.
When I try open page I get error:
InvalidArgumentException in AuthManager.php line 99:
Auth guard driver [api] is not defined.
How can I fix it? I made everything that was need
I'm not sure, please check you guard driver setup into config/auth.php first. You can cross check this from GIT repo.
Let me know if any concern from above.
If you are using tymondesigns/jwt-auth package first check that you are downloading the latest version (1.0.0-rc.2 for this time) or you can just update your composer
composer update
and also delete your old jwt file from config folder and publish again also run!
php artisan jwt:secret

Undefined class Route (Laravel in PhpStorm)

How can I fix this alert in PhpStorm?
And also how to get autocompletion for Route and other Facades?
Check the Laracasts walkthrough
1) Go to: https://github.com/barryvdh/laravel-ide-helper
2) Click on the gist
Generated version for L5: https://gist.github.com/barryvdh/5227822
3) Click on "Raw" to get the current version (as of June 22, 2016 it is):
https://gist.githubusercontent.com/barryvdh/5227822/raw/4d4b0ca26055fa4753b38edeb94fad2396c497c0/_ide_helper.php
4) Make sure you're in your root directory (this is mine)
cd /var/www/html/project
5) Download the gist:
wget https://gist.githubusercontent.com/barryvdh/5227822/raw/4d4b0ca26055fa4753b38edeb94fad2396c497c0/_ide_helper.php
6) Add "_ide_helper.php" to the .gitignore file
sudo nano .gitignore
Add "_ide_helper.php" on a new line at the bottom
7) Download the .gitignore and _ide_helper.php files into PhpStorm
This is what my PhpStorm project directory looks like afterwards:
8) After the files are downloaded into PhpStorm, the "Undefined class" error will disappear and autocompletion will now work. Might need to restart it.
There is greate IDE support for Laravel shipped from Baryvdh:
https://github.com/barryvdh/laravel-ide-helper
after you install it you just call in the console:
php artisan ide-helper:generate
which generate alll facede shortcuts in _ide_helper.php file (which you have to exclude from git)
There is also something special for PhpStorm:
php artisan ide-helper:meta
which will give Laravel container context for example:
$foo = app(Foo::class);
PhpStorm will know that the $foo variable is type of Foo class.
I know this is an old thread, but it is still relevant. For me, I decided to add the following to my routes/web.php since I don't want to have to worry about regenerating meta data for the app.
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
Edit: The above does not add any overhead to PHP as the use simply acts as a reference for PHP.
I solved this problem simply by installing the Laravel idea plugin.
Use the following link:
https://laravel-idea.com/
You can install it on your phpstorm.
Its good feature is that you can use it for 30 days for free and pay the amount after satisfaction.

API Class not found using Composer

I am new to using composer, I have it installed, created composer.json file. Installed bigcommerce api using these instructions: https://github.com/bigcommerce/bigcommerce-api-php
When I try to run "use Bigcommerce\Api\Client as Bigcommerce" I am getting error class not found.
I am using localhost and my file structure is:
testsite
src-> contains all classes including Client.php
vendor -> bigcommerce -> api -> the api files,
api.php -> my test file trying to connect to api
I have not changed any composer files, I have looked into autoloading. As I said before it is first time using composer.
Please read the documentation of Composer here: https://getcomposer.org/doc/00-intro.md Pay attention to the last couple of paragraphs, "Using Composer" and "Autoloading". Did you follow the procedures in your code?

Resources