Error:
Cell class Audit.AuditCell is missing. Cake\View\Exception\MissingCellException
Plugin files:
plugins/Audit/src/Template/Cell/Audit/model.ctp
plugins/Audit/src/View/Cell/AuditCell.php
In, src/Template/Servers/view.ctp:
echo $this->cell('Audit.Audit::model', [strtolower($this->request->controller), $this->request->pass[0]]);
In, config/bootstrap.php:
Plugin::load('Audit', ['bootstrap' => true, 'routes' => true]);
Using CakePHP 3.3.16.
Edit #1
Snapshot of my IDE:
Edit #2
Relevant parts of my composer.json
"require": {
"php": ">=5.5.9",
"cakephp/cakephp": "3.3.*",
"mobiledetect/mobiledetectlib": "2.*",
"cakephp/migrations": "~1.0",
"cakephp/plugin-installer": "*",
"adayth/cakephp-cipher-behavior": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "src",
"Audit\\": "./plugins/Audit/src"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests",
"Audit\\Test\\": "./plugins/Audit/tests"
}
I added the proper namespace Audit\View\Cell to my file.
Related
I am trying to get my app to redirect to the Facebook login page so I can access thee Graph API endpoints.
In bootstrap/app.php have
$app->register(App\Providers\AuthServiceProvider::class);
// $app->register(App\Providers\EventServiceProvider::class);
class_alias(Laravel\Socialite\Facades\Socialite::class, 'Socialite');
$app->register(Laravel\Socialite\SocialiteServiceProvider::class);
My controller is:
<?php
namespace App\Http\Controllers\Facebook;
use App\Http\Controllers\Controller;
use Laravel\Socialite\Facades\Socialite;
class FacebookController extends Controller
{
public function redirectToProvider(Request $request)
{
return Socialite::with('facebook')->redirect();
}
public function handleProviderCallback(Request $request)
{
//here you hadle input user data
$user = Socialite::with('facebook')->user();
}
}
My routes:
Route::get('facebook','App\Http\Controllers\AuthController#redirectToProvider');
Route::get('callback','App\Http\Controllers\AuthController#handleProviderCallback');
My composer.json
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.2.5",
"facebook/graph-sdk": "^5.6",
"laravel/lumen-framework": "^7.0",
"laravel/socialite": "^4.2",
"laravel/ui": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^8.5"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
}
}
All posts I have seen use the config/servcies.php or config/app.php files however I cannot and these files in lumen
Unsure if this is helpful but get these errors when go to the http://local/admin/facebook/login page
at /Applications/MAMP/htdocs/facebook/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:230
at Laravel\Lumen\Application->handleDispatcherResponse(array(0))
(/Applications/MAMP/htdocs/facebook/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:170)
at Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(object(Request))
(/Applications/MAMP/htdocs/facebook/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:426)
at Laravel\Lumen\Application->sendThroughPipeline(array(), object(Closure))
(/Applications/MAMP/htdocs/facebook/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:172)
at Laravel\Lumen\Application->dispatch(null)
(/Applications/MAMP/htdocs/facebook/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:109)
at Laravel\Lumen\Application->run()
(/Applications/MAMP/htdocs/facebook/public/index.php:28)
I've installed FactoryMuffin via composer. After installation, I ran composer dump-autload just to make sure I was using the latest stuff.
Now, when I try to use in my code something from the package I installed I can't. For instance:
use League\FactoryMuffin\Facade;
class APITest extends Sw_Test_PHPUnit_LibraryTestCase
{
public function setUp()
{
$a = new FactoryMuffin();
parent::setUp();
}
}
When I hover over the new FactoryMuffin object instantiation, it says it cannot find its declaration.
If I hover over Facade in:
use League\FactoryMuffin\Facade;
it says
Undefined class Facade
and when hovering over:
use League\FactoryMuffin
it says
multiple implementations
I'm following all the steps listed in the documentation for FactoryMuffin, what am I missing?
Here's my composer file:
{
"name": "project/project",
"description": "Main Project Library",
"homepage": "http://www.testproject.com/",
"require": {
"php": ">=5.4",
"zendframework/zendframework": "2.3.9",
"guzzle/guzzle": "~3.7",
"justinrainbow/json-schema": "~1.3",
"mikey179/vfsStream": "v1.2.0",
"mtdowling/cron-expression": "1.0.*",
"minfraud/http": ">=1.60,<2.0",
"davegardnerisme/nsqphp": "dev-master",
"myclabs/deep-copy": "1.3.0",
"maennchen/zipstream-php": "0.3.*",
"corneltek/getoptionkit": "~2",
"firebase/php-jwt": "~3.0",
"symfony/property-access": "~3.0",
"punic/punic": "2.1.*",
"guzzlehttp/guzzle": "^6.3",
"easypost/easypost-php": "^3.4",
"textalk/websocket": "^1.2",
"robmorgan/phinx": "^0.10.6",
"fzaninotto/faker": "^1.8",
"league/factory-muffin": "^3.0",
"league/factory-muffin-faker": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "5.6.*",
"mockery/mockery": "dev-master"
},
"repositories": [],
"autoload": {
"psr-0": {
"DeepCopy": "vendor/myclabs/deep-copy/src"
}
}
}
https://factory-muffin.thephpleague.com/usage/examples/
Try using as
use League\FactoryMuffin\Facade as FactoryMuffin;
FactoryMuffin::define('Message', array(
'user_id' => 'factory|User',
'subject' => 'sentence',
'message' => 'text',
'phone_number' => 'randomNumber|8',
'created' => 'date|Ymd h:s',
'slug' => 'call|makeSlug|word',
), function ($object, $saved) {
// we're taking advantage of the callback functionality here
$object->message .= '!';
});
I'm new with namespaces and I'm making tests but when I run app.php I get the next error:
Fatal error: Class 'ProtocoloWT\models\status' not found in
C:\xampp\htdocs\wt.uptkd\protocoloWt\app.php
.
app.php
use Neomerx\JsonApi\Encoder\Encoder;
use Neomerx\JsonApi\Encoder\EncoderOptions;
use ProtocoloWT\models\status;
require '../vendor/autoload.php';
$status = status::instance(http_response_code(204));
$encoder = Encoder::instance([
'\status' => '\statusEsquema',
], new EncoderOptions(JSON_PRETTY_PRINT, 'http://example.com/api/v1'));
echo $encoder->encodeData($status);
status.php
namespace ProtocoloWT\models;
class status
{
public static function instance ($status)
{
$estado = new status();
$estado->status = $status;
return $estado;
}
}
composer.json
{
"name": "neomerx/json-api",
"description": "Framework agnostic JSON API (jsonapi.org) implementation",
"keywords": [
"jsonapi.org",
"json-api",
"jsonapi",
"neomerx",
"json",
"api"
],
"homepage": "https://github.com/neomerx/json-api",
"support": {
"issues": "https://github.com/neomerx/json-api/issues"
},
"license": "Apache-2.0",
"authors": [
{
"name": "neomerx",
"email": "info#neomerx.com"
}
],
"require": {
"php": ">=5.5.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6 || ^5.0 || ^6.0",
"mockery/mockery": "~0.9.4",
"scrutinizer/ocular": "^1.3",
"squizlabs/php_codesniffer": "^2.5",
"monolog/monolog": "^1.18",
"phpmd/phpmd": "^2.6"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Neomerx\\JsonApi\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Neomerx\\Tests\\JsonApi\\": "tests/",
"Neomerx\\Samples\\JsonApi\\": "sample/"
}
},
"scripts": {
"test": ["#test-unit", "#test-cs", "#test-md"],
"test-unit": "./vendor/phpunit/phpunit/phpunit --coverage-text",
"test-unit-with-coverage": "phpdbg -qrr ./vendor/bin/phpunit --coverage-text",
"test-cs": "./vendor/bin/phpcs -p -s --standard=PSR2 ./src ./tests",
"test-md": "./vendor/bin/phpmd ./src text codesize,controversial,cleancode,design,unusedcode,naming",
"perf-php": "docker-compose run --rm cli_php php /app/sample/sample.php -t=10000",
"perf-hhvm": "docker-compose run --rm cli_hhvm hhvm /app/sample/sample.php -t=10000"
}
}
File app.php is in a directory called protocoloWT/ and status.php is in protocoloWT/models.
I installed a framework with composer and I can use those namespaces (Neomerx\JsonApi), but I can't create my own namespaces in my files because I get that error. What could be the issue?
PS: Sorry for my english, I have tried to explain it the best I can
I have this in my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"alchemy/zippy": "^0.4.8",
"barryvdh/laravel-debugbar": "^3.1",
"fideloper/proxy": "~3.3",
"graham-campbell/exceptions": "^10.0",
"intervention/image": "^2.4",
"intervention/imagecache": "^2.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.5",
"symfony/dom-crawler": "^3.3"
},
"files": [
"vendor/redbutton/text-image-alpha/vendor/autoload.php"
],
"require-dev": {
"filp/whoops": "^2.1",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
The php files for my package are in a laravel installation:
/vendor/redbutton/text-image-alpha/src/
When I try to call a file I get the message:
Class 'Class 'RedButton\TextImageAlpha\TextImageAlpha' not found' not found
I use this to try and call the class:
$image = new \RedButton\TextImageAlpha\TextImageAlpha( 'some string' );
The file in /vendor/redbutton/text-image-alpha/src/TextImageAlpha.php looks like this:
<?php
namespace RedButton\TextImageAlpha;
use RedButton\TextImageAlpha\Exceptions;
use RedButton\Tools\Objects;
/**
* TextImageAlpha class convert a text to image.
*
* #author Tomas Rathouz <trathouz at gmail.com>
*/
class TextImageAlpha
{
// lots of code
}
This is my first composer package and I don't really have an idea of what is going wrong here. Could someone please explain to me what I'm doing wrong?
Good news. I've looked at your package at Bitbucket and you're doing it right in its composer.json:
Drop unnecessary code from composer.json
I've noticed in pasted composer.json there is manual adding of some vendor file.
"files": [
"vendor/redbutton/text-image-alpha/vendor/autoload.php"
],
/vendor nested in /vendor doesn't make sense as it might duplicate autoloading and break it.
Also I don't see redbutton/text-image-alpha in require section, where it should be.
How to add package the right way?
To install your package just call composer:
composer require redbutton/text-image-alpha
And that's it.
It should appear in require section in composer.json. Composer will autoload it by rules in composer.json of the package - here.
Test
I've tried following code and class is found correctly:
<?php
require __DIR__ . '/vendor/autoload.php';
$image = new \RedButton\TextImageAlpha\TextImageAlpha('some string');
var_dump($image);
Having composer.json:
{
"require": {
"redbutton/text-image-alpha": "^1.0"
}
}
I am following the directions given here to install neoclient on Windows 7 -
https://github.com/neoxygen/neo4j-neoclient
But I get the error -
<b>Parse error</b>: syntax error, unexpected 'use' (T_USE) in <b>C:\xampp\htdocs\send.php</b> on line <b>7</b><br />
when I try to run the sample php code.
My code is -
<?php
try
{
require_once 'vendor/autoload.php';
use Neoxygen\NeoClient\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('default','http','localhost',7474)
->build();
$version = $client->getNeo4jVersion();
}
catch(Exception $e)
{
echo $e->getMessage();
}
echo $version;
?>
composer.json -
{
"name": "neoxygen/neoclient",
"type": "library",
"description": "NeoClient is the most advanced Http Client for Neo4j",
"keywords": [
"graph",
"neo4j",
"cluster",
"client",
"high-availibility"
],
"homepage": "http://neoxygen.io",
"license": "MIT",
"authors": [
{
"name": "Christophe Willemsen",
"email": "chris#neoxygen.io"
}
],
"require": {
"php": ">= 5.5",
"guzzlehttp/guzzle": "^6.0",
"monolog/monolog": "~1.1",
"symfony/yaml": "^2.7",
"symfony/config": "^2.7",
"symfony/dependency-injection": "^2.7",
"symfony/event-dispatcher": "^2.7",
"graphaware/neo4j-response-formatter": "^1.0"
},
"require-dev": {
"phpspec/phpspec": "~2.0",
"phpunit/phpunit": "4.*",
"bossa/phpspec2-expect": "*",
"behat/behat": "~3.0"
},
"autoload": {
"psr-4": {
"Neoxygen\\NeoClient\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Neoxygen\\NeoClient\\Tests\\": "tests/Neoxygen/NeoClient/Tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
}
}
I'm the maintainer of NeoClient.
I don't think I have ever seen this piece of code somewhere, please point to a link.
Especially, require and use statements should be in the beginning of the file, after the open tag.
Secondly, you don't need to instantiate the client in a try/catch block.
Here is the correct piece of code :
<?php
require_once 'vendor/autoload.php';
use Neoxygen\NeoClient\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('default','http','localhost',7474)
->build();
try
{
$version = $client->getNeo4jVersion();
}
catch(Exception $e)
{
echo $e->getMessage();
}
echo $version;
?>