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?
Related
I am currently working on an API only laravel application. In the controllers folder, there is an API folder that holds all controllers. The ForgotPasswordController is in the API folder as well.
When I run the command php artisan route:list I get the error below
Illuminate\Contracts\Container\BindingResolutionException : Target class [App\Http\Controllers\Auth\ForgotPasswordController] does not exist.
There is actually no ForgotPasswordController in the Auth folder. How do I handle this issue?
You have to make sure you are doing php artisan route:cache priority.
If the problem still persists, can you disable the auth provider and try?
For the sake of time considering that the project is live and I need to churn out a couple of features, I have moved both ForgotPassword and ResetPassword controllers back into the Auth folder. Ran a test to make sure nothing has been broken (everything works fine) and now I am able to list out the routes.
If you have Auth::routes() or Route::auth() in your routes file that would be generating routes to the ForgotPasswordController.
You would need to not be calling that or you would need to pass the proper option to it to have it not register those routes:
Auth::routes(['reset' => false]);
Depending on the version you are using this may not work. If that is the case you will have to not use this method at all and register the routes you want/need yourself.
i want to use Requests for PHP in my yii project.
I installed the yii2 basic template, and copied the Requests Class File (and the Requests directory) to root/vendor.
I include the requests.php file with this line
include('../vendor/Requests.php');
But i always get an error that yii cant find the requests.php class.
What i need to do to implement the requests class?
Use Composer, as proposed in project README. Run this command in root of your project:
composer require rmccue/requests
I am trying to set up a multi-site architecture in Symfony 4 using multiple Kernels.
It would be too lengthy to post all of the changes I have made but I basically followed the Symfony docs for creating a new Kernel and the changes I made can be viewed in the following pull request.
When I attempt to run the api kernel locally (php bin/api server:run) I get the following error message:
I am simply trying to load the home controller and template using the new Kernel
# config/api/routes.yaml
home:
path: /
controller: App\Controller\Home::index
Place routes.yaml under config/routes directory, otherwise Symfony treats this file as a framework configuration file.
Or you can reconfigure kernel to load routes files from api directory by editig configureContainer and configureRoutes methods of ApiKernel.
I am just picking up using Laravel, but I dont like Vue and have been working with the React ecosystem and would like to use React instead of Vue. Laravel Mix doesnt give me the setup I want and so I figured I could use create-react-app.
Using Laravel Valet, I have started a project in which I have also installed create-react-app in a folder called ui, at the root of the Laravel installation.
My idea is to forego some of Laravel's functionality, namely the whole frontend.
I am attempting to require the react app build html file in resources/views/main.blade.php like so:
require_once __DIR__.'/ui/build/index.html';
This gives me the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
(E_UNKNOWN) Illuminate\View\Engines\PhpEngine::main(): Failed opening
required
'/Users/Username/Sites/sitename/storage/framework/views/ui/build/index.html'
(include_path='.:')
This path is not correct, but I'm not sure why it is inserting /storage/framework/ into that path.
I have also tried the following, each with a similar error of Failed opening resource:
require_once('../../ui/build/index.html');
require_once($_SERVER['DOCUMENT_ROOT'].'/ui/build/index.html');
require_once(dirname(__FILE__).'/ui/build/index.html');
Laravel does not integrate with Vue, and Laravel Mix is a simple layer on top of Webpack. The default Laravel application ships with Vue scaffolding but removing that is as simple as deleting the files in resources/assets/js and if you wish to use another Javascript library then you can add that into your app.js instead.
The error you're receiving is because Laravel caches view files, meaning that they're served from the cache directory (which lives in storage/framework) so references like __DIR__ are referencing the cache directory, not the resources directory. You can see this in the documentation:
You should avoid using the DIR and FILE constants in your Blade views, since they will refer to the location of the cached, compiled view.
The correct approach to include files into your views with Blade is using the #include directive, e.g:
#include('ui.build.index')
Also, worth noting, that any time you do need to obtain the path to a file in your Laravel application you should use the base_path and app_path helpers.
Prior to continuing with development of your application you should read through the JavaScript & CSS Scaffolding documentation and the Blade documentation, as they contain a lot of information that will be very useful to you — for example, it explains how to replace Vue with React using a single command.
I'm attempting to build a test project with the Zend framework and using MAMP to run it on my local host.
The project creation works fine; I navigate to my htdocs directory and use zf create project my_zend to create the scaffold.
My error comes when I try to create a controller "students" by using the following command zf create controller students, however, once this command runs it outputs the following error:
Context by name servicesDirectory does not exist in the registry.
Where does this error come from?
I had the same problem, here is how I fixed it, check for the line:
<servicesDirectory enabled="false"/>
In the .zfproject.xml file and remove it.
You might get this error if you have another version of zend some where in the path. If you have one try deleting it and using the latest or the version you wish to. This worked for me in xamp on windows 7 hope it works for you