What file contains the Laravel version info? - laravel

I'm looking at cloning a project from Github, but the readme.md file doesn't include what version of Laravel it's built on.
How can I see what version it is, without pulling it down and running php artisan -v?
Is there a specific file in a directory that contains it? (I'm guessing it's where the artisan command looks?)

The constant VERSION in Illuminate/Foundation/Application.php tells you what version they are running.
class Application extends Container implements ApplicationContract, HttpKernelInterface
{
/**
* The Laravel framework version.
*
* #var string
*/
const VERSION = '5.6.26';
If the project is using Composer, check for the laravel/framework requirement in the require rule in composer.json.
{
"require": {
"laravel/framework": "5.6.*"
}
}

Related

Run Laravel Seeder From Package

I'm working on a package for an internal Laravel application and I'm having trouble running a seeder that exists in the package directory.
In my package's composer.json file located in packages/vendor/packagename, I've added the following:
"autoload": {
"psr-4": {
"Vendor\\PackageName\\": "src/",
"Vendor\\PackageName\\Database\\Factories\\": "database/factories/",
"Vendor\\PackageName\\Database\\Seeders\\": "database/seeders/"
}
},
I have the following file located in "packages/vendor/packagename/database/seeders/DepartmentSeeder.php"
<?php
namespace Vendor\PackageName\Database\Seeders;
use Illuminate\Database\Seeder;
use Vendor\PackageName\Models\Department;
class DepartmentSeeder extends Seeder
{
/**
* Run the database seeds.
*
* #return void
*/
public function run()
{
Department::factory()->count(10)->create();
}
}
I then attempt to run the following command:
$ php artisan db:seed --class="Vendor\\PackageName\\Database\\Seeders\\DepartmentSeeder"
Target class [Vendor\PackageName\Database\Seeders\DepartmentSeeder] does not exist.
If I move the seeders directory into my src directory and run the following, it works, but I'd rather keep my seeders in my database directory.
$ php artisan db:seed --class="Vendor\\PackageName\\seeders\\DepartmentSeeder"
Does anyone have any idea why the class isn't being found? All my Google search results are purple and I even went to page two =/
Solution
In my particular case, composer dump-autoload wasn't doing the trick. What I ended up doing was running composer update vendor/packagename and whatever the issue was, it was resolved.
Hopefully, this helps anyone else who may have similar issues.
In my particular case, composer dump-autoload wasn't doing the trick. What I ended up doing was running composer update vendor/packagename and whatever the issue was, it was resolved.
Hopefully, this helps anyone else who may have similar issues.

Target class [redirect] does not exist lumen version 7

Lumen Version: Lumen (7.2.2)
Laravel Version: ^7.0
PHP Version: 7.3.27
Description:
Having problem with error Target class [redirect] does not exist.
This line of code:
$router->get('/', function () use ($router) {
return redirect('/somewhere');
});
return error :
Target class [redirect] does not exist. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [redirect] does not exist. at /var/www/apidev/vendor/laravel/framework/src/Illuminate/Container/Container.php:811)
It might be some artifacts if you manage Lumen project for long time and did few major version updates for the framework.
In my case there was no any dependencies in the composer.json file, but inside vendor folder really there was Laravel framework files which created those conflitcs with helper functions.
composer remove laravel/framework in the project folder made
all necessary package updates and error is gone.

Laravel 5.8 Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

Objective: Changing columns in MySQL with laravel migration, however raises the error below
To change columns in mysql tables using migration requires the installation of the 'doctrine / dbal' dependency. Read the documentation on the link beside [https://laravel.com/docs/5.8/migrations#modifying-columns][1]
Wrong choice for laravel 5.8: $ composer require doctrine/dbal
Problem:
$ php artisan migrate
Migrating: 2021_01_14_031415_my_chage_migrate
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found
at ...\vendor\laravel\framework\src\Illuminate\Database\MySqlConnection.php:65
61| * #return \Doctrine\DBAL\Driver\PDOMySql\Driver
62| */
63| protected function getDoctrineDriver()
64| {
> 65| return new DoctrineDriver;
66| }
67|
68| /**
69| * Bind values to their parameters in the given statement.
Exception trace:
Solution:
$ composer remove doctrine/dbal
$ composer require doctrine/dbal:2.*
I hope it helps someone, good luck
;)
dotring/dbal 2.12.1 is the last stable version;
1.composer require doctrine/dbal:2.12.1
2.composer update

Nova Tool not updating

I'm making a Laravel Nova app. I'm trying to create a Nova Tool to import users.
The tool creates just fine, however when i update the code it does not show.
I've digged a bit into this, and the problem seems to be that the tool in the Vendor folder does not get updated.
When i do npm run dev or npm run prod, the tool files get updated inside the /nova-components/{componentname} folder, and not in the vendor folder, which is getting loaded by Nova.
I'm using Xampp on windows.
Inside my nova service provider:
/**
* Get the tools that should be listed in the Nova sidebar.
*
* #return array
*/
public function tools()
{
return [
new UserImport()
];
}
My composer file:
"require": {
"Vrumona/UserImport": "*"
},
"repositories": [
{
"type": "path",
"url": "./nova"
},
{
"type": "path",
"url": "./nova-components/UserImport"
}
],
How do make sure the Tool gets updated in the composer vendor folder?
I can delete the vendor folder and run composer install, but this is a bit tedious while developping.
Thanks!
It is likely that composer is not symlinking the package but rather mirroring. You can confirm by seeing what the output is when you run composer update -- if you see Mirrored from ... then symlinks are unavailable which will cause the issue that you're seeing.
As you noticed, you can force symlinks in the composer file using:
"options": {
"symlink": true // Will force symlinks
}
And the relevant documentation if needed: https://getcomposer.org/doc/05-repositories.md#path
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear

CodeIgniter + omnipay installation

I have used ci-merchant before but from everything see that the "V2" of it is now omnipay. I use codeigniter and i'm struggling to get even the example to work.
I have installed omnipay no problems and in my controller have the following:
use Omnipay\Common\GatewayFactory;
class Homepage extends BC_basecontroller {
public function index()
{
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername('adrian');
$gateway->setPassword('12345');
}
}
Which is the example here: https://github.com/adrianmacneil/omnipay
However I get the error:
PHP Fatal error: Class 'Omnipay\Common\GatewayFactory' not found in......
Does anyone know how to get it to work in CI?
I'm not sure how you installed Omnipay, but you need to use Composer to load the classes before you can use them.
So following the Omnipay installation instructions, add this to a composer.json file in your root directory:
{
"require": {
"omnipay/omnipay": "*"
}
}
Then install the files:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
Now, if you are using CodeIgniter you will need to set it up to include the composer autoloader. Basically, just add this line to the top of your index.php file:
require_once __DIR__.'/vendor/autoload.php';
There is also a tutorial on using Composer with CodeIgniter here which you may find helpful: http://philsturgeon.co.uk/blog/2012/05/composer-with-codeigniter
I had the same error and fixed it by loading vendor/autoload.php before application/core/CodeIgniter.php

Resources