Missing argument 2 for Illuminate when using command line to create controller - command-line

I am trying to create controller using the command line in laravel but when i SSH to my server and try to run the laravel CLI command php artisan controller:make AboutController
or even any other command like : php artisan list
I always get this message :
{
"error":
{
"type":"ErrorException",
"message":"Missing argument 2 for Illuminate\\Routing\\Router::controller(), called in \/home1\/jokira\/public_html\/laravel\/bootstrap\/compiled.php on line 3155 and defined","file":"\/home1\/jokira\/public_html\/laravel\/bootstrap\/compiled.php","line":4379
}
}
What am i doing wrong ?

Maybe you add some wrong routes to app/routes.php just like what I did.
I add some temp route like this:
//user routes
Route::get('/login');
Route::post('/login');
Route::get('/reg');
Route::post('/reg');
And I got the same errors as you .
After I deleted this lines , all works fine now.
Wish can help you .

You need to specify the path of the route for your controller.
This is wrong example:
Route::controller('AuthController');
And this is the correct one:
Route::controller('/auth', 'AuthController');

Related

Check for empty file and quit cakebuild

I am attempting to write a check in my Cake build script to pull in a file from BuildParameters and check if the file contents are empty -- if contents are empty, throw an exception and quit the build.
I am attempting to use FileReadText from the FileHelpers namespace but for some reason I cannot get my build to recognize the file command. I am following the syntax and documentation found here: https://cakebuild.net/api/Cake.FileHelpers/FileHelperAliases/97F5679A
Here is the code I am trying in build.cake:
var fileReadText= FileReadText(Parameters.TestParameters.TestListFP);
var fileText= fileReadText.ThrowIfNullOrEmpty(nameof(fileReadText));
The argument Parameters.TestParameters.TestListFP is set in my Parameters.cake file as such:
TestListFP = context.File("C:\Some\Path\some_file_name.txt");
Using the above code, I see this error:
error CS0103: The name 'FileReadText' does not exist in the current
context
Note that I do not have a ICakeContext in build.cake, just BuildParameters.
I tried to resolve the issue by adding using Cake.FileHelpers; at the top of my build.cake file, but then I see this error:
The type or namespace name 'FileHelpers' does not exist in the namespace 'Cake' (are you missing an assembly reference?)
The script works fine without my FileReadText code, so I know TestListFP is actually a valid file.
I think I am inherently misunderstanding how to use FileHelpers and FileReadText and I could not find any examples of usage in documentation or anywhere else. If anyone has guidance on how to use this method, or a better way to accomplish what I am trying to do, I would appreciate the help.
Have you added the #addin pre-processor directive, as mentioned here:
https://github.com/cake-contrib/Cake.FileHelpers/#cakefilehelpers
You can easily reference Cake.FileHelpers directly in your build script via a cake addin:
#addin "Cake.FileHelpers"

How to add my own custom class in Laravel 5?

Ok, in laravel 4, if I want to add my own custom class, eg : library\myFunction.php then I do the following steps :
add "myFunctions.php" into app/library/myFunctiosn.php
at app/start/global.php , within ClassLoader::addDirectories(array( , I add app_path().'/library',
And to call it within my blade view, I add the following codes
<?php
$FmyFunctions1 = new myFunctions;
$is_ok1=($FmyFunctions1->is_ok());
?>
The contents of app/library/myFunctions.php is :
<?php namespace App\library {
class myFunctions {
public function is_ok() {
return 'myFunction is OK';
}
}
}
?>
And it works.
But how to do so in Laravel 5 ???
PS : I read What are the best practices and best places for laravel 4 helpers or basic functions?
And tried to add "app/library/", to the autoload array and run composer dum-autoload , but it keeps give me error :
FatalErrorException in xxxx line xx: Class 'myFunctions' not found
I'm also already trying to use :
composer update
composer dump-autoload
php artisan dump
php artisan clear-compiled
php artisan dump-autoload
php artisan optimize
php artisan route:clear
php artisan route:scan
php artisan route:list
But still doesn't work...
This should help you.
FYI:
Basically, you could create another directory within app, and then namespace your files in there as appropriate:
app/CustomStuff/CustomDirectory/SomeClass.php.
Then, within your SomeClass.php, make sure you namespace it:
<?php
namespace App\CustomStuff\CustomDirectory;
class Someclass {}
Now, you can access this class using the namespace within your classes:
use App\CustomStuff\CustomDirectory\SomeClass;
After some trial and error, I found the answer.
There is no need to modify Composer. Just modify the Blade into:
<?php
$FmyFunctions1 = new \App\library\myFunctions;
$is_ok = ($FmyFunctions1->is_ok());
?>

how to configure doctrine command line tools on zenframework 2

i am using doctrine 2 on zendframework 2. i have configured both correcly and they are both working.
i however wish to use doctrine's command line tool to generate entities etc.
i have followed doctrine's instructions and created a cli-config.php page in the root of my application:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html
i am however lost on two issues;
the configuration requires a bootstrap php page; however, zendframework 2 does not use a bootstrap page; so what would the equivalent be?
Secondly, it requires us to obtain an entity mangager; would the method below be the correct way to get the entity manager:
public function getEntityManager()
{
if (null === $this->em) {
$this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
}
return $this->em;
}
below is how the cli-config.php page should look;
// cli-config.php
require_once 'my_bootstrap.php';
// Any way to access the EntityManager from your application
$em = GetMyEntityManager();
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
i would really appreciate any help or advice on this matter.
warm regards
Andreea
the matter has been resolved:!!
it did not work because i was using a cygdrive command line. however, when i switched to git bash it worked perfectly. with git bash i have to use the command:
C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema
If you have started your project using the Zend Skeleton Application you do have a composer.json file. You just need to include the DoctrineORMModule (instructions here)
Then, using the CMD just type
C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema
There you go.
Once you have set up doctrine2 and zf2, you should be able to simply run all CLI commands.
php public/index.php orm:generate-entities
Using the parameters as described in the official documentation.
Note: DoctrineModule and DoctrineORMModule need to be enabled within your application.config.php
You need to install the doctrine/doctrine-orm-module with your Composer dependency manager. To do that, cd to your web site's top-level directory and type the following command:
php composer.phar require doctrine/doctrine-orm-module *
After executing this command, the DoctrineModule and DoctrineOrmModule will be installed into your vendor folder, and Doctrine commands will become available.
For more information about DoctrineOrmModule, see this:
https://github.com/doctrine/DoctrineORMModule

JSDoc Templates - "publish" not found

I've been able to get JSDoc3 working with the default template, however, when I try to run another template (even the one that comes with it,haruki) I get the following error:
js: "/path/to/jsdoc/jsdoc.js", line 308: exception from uncaught JavaScript throw: Error: Unable to load template: Module "haruki/publish" not found.
I've tried several other templates and get the same thing. Goven my freshman status with JSDoc I'm assuming it's some config or call issue that's tripping me up.
try to set full path to template folder with publish.js file (not only template name)
for example command line parameter
-t templates/docstrap-master/template
or in config.json file
{ ...
"opts": {
...
"template": "templates/docstrap-master/template"
}
}
it works for this https://github.com/terryweiss/docstrap
for Haruki it seems to work too ./jsdoc -c conf.json -t templates/haruki but i have another error:
This template only supports output to the console. Use the option "-d
console" when you run JSDoc.
With -d console it prints result to console

Opencart Fatal error: Call to a member function get() on a non-object

Trying to move from local host to new server. Fresh install worked fine, no problems. When I uploaded my files mydomain.com/admin comes up with a white screen and mydomain.com produces this error:
Fatal error: Call to a member function get() on a non-object in /home4/pawpostc/public_html/index.php on line 103.
So I took a look at index.php line 103:
if ($config->get('config_error_display')) {
echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
}
Seems like there is a problem with my config files. So I went and had a look at them. I have gone over them a few times but can not find the mistake, probably missing something, so here are the config files.
config.php (in my root www. folder):
<?php
// HTTP
define('HTTP_SERVER', 'http://www.pawpost.com.au/');
define('HTTP_IMAGE', 'http://www.pawpost.com.au/image/');
define('HTTP_ADMIN', 'http://www.pawpost.com.au/admin/');
// HTTPS
define('HTTPS_SERVER', 'http://www.pawpost.com.au/');
define('HTTPS_IMAGE', 'http://www.pawpost.com.au/image/');
// DIR
define('DIR_APPLICATION', '/home4/pawpostc/public_html/catalog/');
define('DIR_SYSTEM', '/home4/pawpostc/public_html/system/');
define('DIR_DATABASE', '/home4/pawpostc/public_html/system/database/');
define('DIR_LANGUAGE', '/home4/pawpostc/public_html/catalog/language/');
define('DIR_TEMPLATE', '/home4/pawpostc/public_html/catalog/view/theme/');
define('DIR_CONFIG', '/home4/pawpostc/public_html/system/config/');
define('DIR_IMAGE', '/home4/pawpostc/public_html/image/');
define('DIR_CACHE', '/home4/pawpostc/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home4/pawpostc/public_html/download/');
define('DIR_LOGS', '/home4/pawpostc/public_html/system/logs/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'my user name');
define('DB_PASSWORD', 'my password');
define('DB_DATABASE', 'my database');
define('DB_PREFIX', 'oc_');
?>
admin/config.php:
<?php
// HTTP
define('HTTP_SERVER', 'http://www.pawpost.com.au/admin/');
define('HTTP_CATALOG', 'http://www.pawpost.com.au/');
define('HTTP_IMAGE', 'http://www.pawpost.com.au/image/');
// HTTPS
define('HTTPS_SERVER', 'http://www.pawpost.com.au/admin/');
define('HTTPS_CATALOG', 'http://www.pawpost.com.au/');
define('HTTPS_IMAGE', 'http://www.pawpost.com.au/image/');
// DIR
define('DIR_APPLICATION', '/home4/pawpostc/public_html/admin/');
define('DIR_SYSTEM', '/home4/pawpostc/public_html/system/');
define('DIR_DATABASE', '/home4/pawpostc/public_html/system/database/');
define('DIR_LANGUAGE', '/home4/pawpostc/public_html/admin/language/');
define('DIR_TEMPLATE', '/home4/pawpostc/public_html/admin/view/template/');
define('DIR_CONFIG', '/home4/pawpostc/public_html/system/config/');
define('DIR_IMAGE', '/home4/pawpostc/public_html/image/');
define('DIR_CACHE', '/home4/pawpostc/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home4/pawpostc/public_html/download/');
define('DIR_LOGS', '/home4/pawpostc/public_html/system/logs/');
define('DIR_CATALOG', '/home4/pawpostc/public_html/catalog/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'my user name');
define('DB_PASSWORD', 'my password');
define('DB_DATABASE', 'my database');
define('DB_PREFIX', 'oc_');
?>
Any help on this would be appreciated.
I was using opencart and installed vqmod.
All of a sudden I have one of the same errors.
This solved my problem:
in system/library/session.php
replace start session with:
session_save_path(realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../tmp'));
The most likely issue is that one or more of your library files are corrupt from uploading. Re upload your system/library/ folder from your local one. Your config files seem fine and the error doesn't reference a config issue. What is line 103 in your index.php file?
please cross check you have set all permissions
i had came across this error and was solved,
that was due to a file permission problem
I was struggling with the same problem after migrating my site to a new VPS environment. I figured it HAD to be something to do with the changed document-root path or permissions of my shop and pulled out a lot of hair trying to get to the core of the problem.
I finally realised that I had incorrect permissions on my PHP session-data store! In my case, the folder at /var/lib/php/session/ was owned by apache (naturally) but I had changed apache to run as a different user so it could no longer write to the session-store.
The error messages in this case are cryptic (to say the least!) and didn't give a clue that the problem might just be lack of write permission!
Oh well, we should know by now that 90% of unix issues are down to perms!
I upload a file at my server (directory: vqmod/....php ).
Just change vqmod file permission. I set 777 and that solved it.
From the error you received, it looks like the $config variable is not getting set.
The $config variable is set on line 35 using the Config class which is located in system/library/config.php
I think if you figure out why the class isn't getting instantiated, you'll be able to fix the issue.
This could be a couple things:
The system/library/config.php file may not have been uploaded to the new server
As mentioned in previous answers, there could be a permissions issue. Check the permissions of system/library/config.php and make sure the correct user has ownership.
Or it could be a completely unrelated issue.
The error is due to permissions set on the cache folder. Setting that to 755 and the files to 555 with set you home and dry.
I had the same issue. I changed vqmod permission to 777. I am not sure this solved the problem, but I checked my website without adding www. before the domain and it worked. The warning was removed if I check http://daytodaystore.com. If I check http://www.daytodaystore.com, the warning is there.
I had this problem when i migrated my server from 2G to 4GH on Godaddy.
Came across this forum and found that the issue is with session.php
Then, i guessed 'tmp' folder was missing. So, i created one just one step above html folder. and gave it a 777 access. Problem was fixed and my website looks great after that.