I'm working on a php project and need to use the Collection namespace from Illuminate. I have Laravel installed on my computer. However, when I try and create a new collection with:
use Illuminate\Support\Collection;
$collection = new Collection();
It gives me the error that it cannot find the class Illuminate\Support\Collection. I tried moving my Laravel folder into the same directory as the project and that didn't work either. I also tried looking through my laravel folders and couldn't find the Illuminate files anywhere. Do I have to do a separate installation to get the Illuminate libraries? Any help is appreciated.
Related
I am upgrading laravel from 5.3 to 5.4. I tried both way, but updating composer or download new laravel 5.4 and paste directory in it.
I am getting error:
In Container.php line 729:
Class hash does not exist
Note: Composer update successfully.
Please us following.
use Illuminate\Support\Facades\Hash;
i hope it helps.
Please use following when error comes same as below picture
Now go to project (root folder) -> storage -> framework
and check that there are views folder exist or not. If there are views folder (C:\xampp\htdocs\project\storage\framework\views) not exist then you should create new folder views and then run your project.
In my case, 3-4 months facing issue and then i saved my project.
I can access the list of files in a directory in Laravel using this:
use File;
....
$files = File::files($path);
However, I get this error in lumen:
Class 'File' not found
Any idea how I can access list of files in a folder in lumen.
File is only avaiable in Laravel by default. Although you can still used it on Lumen Framework by doing the following.
Enable the facade in boostrap/app.php by uncommenting the following code.
$app->withFacades();
After that, you will be able to access the File class in any of your controller by adding it as:
use Illuminate\Http\File;
or you can use the Facade Class.
use Illuminate\Support\Facades\File;
Please do a composer dump-autoload to update autoload.
I am creating a REST API with Laravel 5.2 and I'm also using MongoDB with the jenssegers/mongodb library. I have a virtualhost for my application so I can go to the url eg: http://myapp.local.com and simulate how it would be on the real server and as I have some other Laravel projects on dev right now, it is more organised to have them this way.
The virtualhost is pointing to the public folder of my application and it's working correctly.
This project is just starting so everything is being built right now. In order to check the database I created a very simple PostsController just to see if the connection and the results were returned correctly. I added Route::resource('/posts', 'PostsController'); in my routes.php so I could start doing some tests of basic CRUD operations.
When I use php artisan serve and access this route with http://localhost:8000/posts the results are brought correctly but when I try to access via http://myapp.local.com/posts I get this error:
FatalErrorException in Client.php line 56:
Class 'MongoDB\Driver\Manager' not found
Any ideas why this is happening?
I have developed an application with Laravel, version 5.1, using homestead to test.
When I place it on the production server, I get this error that I can't replicate on the local machine:
ReflectionException in Container.php line 736
Class MyMultiSelect does not exist
This class is a sleeping-owl Custom Form Item
http://sleeping-owl.github.io/en/Form_Elements/Custom_Form_Elements.html
I checked for:
namespace errors / conflicts
I even placed the class in the global namespace
tried to load the file containing the class in composer.json
Filename: MyMultiSelect.php
Class: MyMultiSelect
namespace: Global so to access it \MyMultiSelect
admin/bootstrap.php
FormItem::register('myMultiSelect', \MyMultiSelect::class);
Can anyone help me?
Run composer dump-autoload on your server. This will rebuild the autoloader cache, that stores paths to classes. If your paths are different locally and on the server, this could help.
I am working on a project in php Phalcon.
I am working with the Xampp server. The installation process that I followed is on this link:
http://docs.phalconphp.com/en/latest/reference/install.html
I am following the documentation on the website as guide and tutorial.
My problem is, every time I type "class MyClass extends \Phalcon\Mvc\Model"
it says undefined namespace "Mvc" and in other files it also gives error that Phalcon is an undefined namespace.
The installation seems okay.
Please help me out.
I think this is not really a problem with the installation of Phalcon.
I have recognized the same behaviour of my IDE because Phalcon is only loaded as an extension of PHP and not available as real PHP files which can be indexed by your IDE.
The easiest way to check if install was ok is to create a info.php in your project root.
<?php
phpinfo();
If you open this file in browser it should show a block with information about phalcon.
There is a script that creates stub files for you that can be integrated in you project.
https://github.com/phalcon/phalcon-devtools/blob/master/ide/gen-stubs.php
If these files are indexed by your IDE, the message of Undefined namespace should be gone.
If your code works. And IDE shows Mvc undefined namespace then you have to install Phalcon developer tool plugin for your IDE. the plugin is available for PHPStorm. Phalcon is a C extention and for this if you not install developer tool plugin then IDE will show undefined namespace.
Phalcon has different ways to use model like register model class, register namespace or register dir. If you create the model by command rather than manually write code you will get the proper base model class to extend. If still problem then there is problem with Phalcon installation.
Use --namespace="" for model:
phalcon create-model profiles --namespace="Application\Models"
For scaffold:
phalcon create-scaffold profiles --ns-models="Application\Models" --ns-controllers="Application\Controllers"
If you do not register the model namespace and register only model directory then edit the model file after creation and remove the namespace definition.
first check if php load phalcon module. for that in terminal type
php -r "echo phpinfo();" | grep 'phalcon'
if everything went write you should see line
phalcon => enabled
in windows grep wont work and you should look for that line yourself.