PHP - Silex: Fatal error: Class not found - php

I've made a PHP application with Silex. I'm using a WAMP solution on my laptop to develop, in combination with Composer.
Now, when I upload the application (maps 'app', 'src' and 'web') and upload the database, change the config.php to the correct database credentials I issue the composer command (composer.phar -o install) to install the vendor dependencies.
Until this point everything works, Composer makes the 'vendor' map and installs the dependencies without errors. But when I visit the website it shows me the error:
Fatal error: Class 'WanaKo\Provider\Controller\HomeController' not found in /home/wanako/domains/wanako.net/app/app.php on line 37
What can I do to fix that error? I must add that the server is running DirectAdmin with PHP 5.5.16 and that I've made a symlink from 'public_html/' to 'web/'
The directory structure is:
/home/wanako/domains/wanako.net/
├── app
├── logs
├── public_ftp
│ └── incoming
├── public_html -> web/
├── src
│ ├── wanako
│ │ ├── provider
│ │ │ └── controller
│ │ └── repository
│ └── views
│ ├── errors
│ └── home
├── vendor
│ ├── composer
│ ├── doctrine
│ │ ├── common
│ │ └── dbal
│ ├── igorw
│ │ └── config-service-provider
│ ├── imagine
│ │ └── imagine
│ ├── ircmaxell
│ │ └── password-compat
│ ├── knplabs
│ │ └── repository-service-provider
│ ├── monolog
│ │ └── monolog
│ ├── neutron
│ │ └── silex-imagine-provider
│ ├── pimple
│ │ └── pimple
│ ├── psr
│ │ └── log
│ ├── silex
│ │ └── silex
│ ├── swiftmailer
│ │ └── swiftmailer
│ ├── symfony
│ │ ├── config
│ │ ├── debug
│ │ ├── event-dispatcher
│ │ ├── filesystem
│ │ ├── form
│ │ ├── http-foundation
│ │ ├── http-kernel
│ │ ├── icu
│ │ ├── intl
│ │ ├── locale
│ │ ├── options-resolver
│ │ ├── property-access
│ │ ├── routing
│ │ ├── security-core
│ │ ├── security-csrf
│ │ ├── translation
│ │ ├── twig-bridge
│ │ └── validator
│ └── twig
│ └── twig
└── web
├── css
├── font
├── images
└── js
composer.json
{
"name": "Wanako/Wakano.net",
"require": {
"silex/silex": "1.0.*#dev",
"twig/twig": ">=1.8,<2.0-dev",
"doctrine/dbal": "2.*",
"knplabs/repository-service-provider": "dev-master",
"symfony/twig-bridge": "~2.1",
"symfony/form": "~2.1",
"symfony/validator": "~2.1",
"symfony/config": "~2.1",
"symfony/translation": "~2.1",
"symfony/locale": "~2.1",
"monolog/monolog": ">=1.0.0",
"igorw/config-service-provider": "~1.1",
"swiftmailer/swiftmailer": ">=4.1.2,<4.2-dev",
"ircmaxell/password-compat": "dev-master",
"neutron/silex-imagine-provider": "~0.1"
},
"autoload": {
"psr-0": {
"WanaKo": "./src/"
}
}
}
At line 37 of app/app.php I've got:
$app->mount('/', new WanaKo\Provider\Controller\HomeController());
homecontroller.php (in the folder src/wanako/provider/controller/)
<?php
namespace WanaKo\Provider\Controller;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\Validator\Constraints as Assert;
class HomeController implements ControllerProviderInterface {
$controllers = $app['controllers_factory'];
// Bind sub-routes
$controllers->get('/', array($this, 'home'))->method('GET')->bind('home.news');
return $controllers;
}
public function home(Application $app) {
// STUFF
}
I've got no clue on this one. Is there something I did wrong? Wrong folder structure? Something I forgot? If anyone needs more info, just ask. Thanks for helping out!

I believe you have to name your folder structure and files in the correct case for psr0 to work correctly, like this:
src/WanaKo/Provider/Controller/HomeController.php

Related

xampp object not found error after clicking on activation link

I am following one tutorial for signup and sign in using email verification.
It works fine and it sends a confirmation link on provided email id.
It shows:
I have tried adding alies as well but didn't work
I don't know how do i solve it. Please guide me.
File Structure:
C:.
│
│
│
└───signup-email-verification
│ class.user.php
│ dbconfig.php
│ fpass.php
│ home.php
│ index.php
│ logout.php
│ resetpass.php
│ signup.php
│ store-signup.php
│ tbl_users.sql
│ verify.php
│
├───bootstrap
│ ├───css
│ │ bootstrap-responsive.css
│ │ bootstrap-responsive.min.css
│ │ bootstrap.css
│ │ bootstrap.min.css
│ │
│ ├───img
│ │ glyphicons-halflings-white.png
│ │ glyphicons-halflings.png
│ │
│ └───js
│ bootstrap.js
│ bootstrap.min.js
│ jquery-1.9.1.min.js
│
└───mailer
class.phpmailer.php
class.pop3.php
class.smtp.php
I was trying to access below link
localhost/drop2/signup-email-verification/store-signup.php
As you mentioned in your comment, you are trying to access store-signup.php using below URL.
localhost/drop2/signup-email-verification/store-signup.php
Now, as per above URL, your application should be drop2 and store-signup.php resides under signup-email-verification folder. That means, you folder structure should be
drop2
|
|--- signup-email-verification
|
|---store-signup.php
As per your posted folder structure, you don't have drop2 folder itself.
Also, you are suppose to place your project folder under your server root folder not in C: drive.

Empty libs.css and libs.js files

I compiled my styles and scripts using webpack, but I noticed that the libs.css and libs.js files are empty rather I have entries in the app.cs and app.js files. Here are my npm settings:
:- webpack.mix.js:
const { mix } = require('laravel-mix');
mix.js('resources/assets/js/app.js', 'public/js/')
.sass('resources/assets/sass/app.scss', 'public/css/');
mix.styles([
'libs/animate.css',
'libs/animations.css',
'libs/app.css',
'libs/bootstrap-theme.css',
'libs/bootstrap.css',
'libs/custom.css',
'libs/font-awesome.min.css',
'libs/head-custom.css',
'libs/sb-admin-2.css',
'libs/sticky.css',
'libs/style.css',
], './public/css/libs.css');
mix.scripts([
'libs/app.js',
'libs/bootstrap.js',
'libs/custom.js',
'libs/gmap.js',
'libs/ipad.js',
'libs/jquery.form.min.js',
'libs/jquery.min.js',
'libs/jquery.pjax.js',
'libs/jquery.slim.min.js',
'libs/myform.js',
'libs/sb-admin-2.js',
'libs/sb-admin-2.min.js',
'libs/sticky.js',
'libs/template.js',
], './public/js/libs.js');
mix.scripts([
'/plugins/jquery.appear.js',
'/plugins/jquery.backstretch.min.js',
'/plugins/modernizr.js',
'/plugins/libs3/jquery.js',
], './public/js/plugins/plugins.js');
mix.scripts([
'/libs/isotope.pkgd.js',
], './public/js/plugins/isotope/isotope.js');
:- mix-manifest.json:
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css",
"./public/css/libs.css": "./public/css/libs.css",
"./public/js/libs.js": "./public/js/libs.js",
"./public/js/plugins/plugins.js": "./public/js/plugins/plugins.js",
"./public/js/plugins/isotope/isotope.js": "./public/js/plugins/isotope/isotope.js"
}
:- Directory structure of resource folder:
resources/
├── assets
│ ├── css
│ │ └── libs
│ │ ├── animate.css
│ │ ├── animations.css
│ │ ├── app.css
│ │ ├── bootstrap.css
│ │ ├── bootstrap.min.css
│ │ ├── bootstrap-theme.css
│ │ ├── bootstrap-theme.min.css
│ │ ├── custom.css
│ │ ├── font-awesome.min.css
│ │ ├── head-custom.css
│ │ ├── sb-admin-2.css
│ │ ├── sb-admin-2.min.css
│ │ ├── sticky.css
│ │ └── style.css
│ ├── js
│ │ ├── app.js
│ │ ├── bootstrap.js
│ │ ├── components
│ │ │ └── Example.vue
│ │ ├── libs
│ │ │ ├── app.js
│ │ │ ├── bootstrap.js
│ │ │ ├── custom.js
│ │ │ ├── gmap.js
│ │ │ ├── ipad.js
│ │ │ ├── isotope.pkgd.js
│ │ │ ├── jquery.form.min.js
│ │ │ ├── jquery.min.js
│ │ │ ├── jquery.pjax.js
│ │ │ ├── jquery.slim.min.js
│ │ │ ├── myform.js
│ │ │ ├── sb-admin-2.js
│ │ │ ├── sb-admin-2.min.js
│ │ │ ├── sticky.js
│ │ │ └── template.js
│ │ └── plugins
│ │ ├── jquery.appear.js
│ │ ├── jquery.backstretch.min.js
│ │ ├── libs3
│ │ │ └── jquery.js
│ │ └── modernizr.js
│ └── sass
│ ├── app.scss
│ └── _variables.scss
Try this code below...
mix.styles(['resources/assets/css/libs/animate.css', 'resources/assets/css/libs/animations.css', 'resources/assets/css/libs/app.css', 'resources/assets/css/libs/bootstrap-theme.css', 'resources/assets/css/libs/bootstrap.css', 'resources/assets/css/libs/custom.css', 'resources/assets/css/libs/font-awesome.min.css', 'resources/assets/css/libs/head-custom.css', 'resources/assets/css/libs/sb-admin-2.css', 'resources/assets/css/libs/sticky.css', 'resources/assets/css/libs/style.css' ], 'public/css/libs.css', './');
mix.scripts(['resources/assets/js/libs/app.js', 'resources/assets/js/libs/bootstrap.js', 'resources/assets/js/libs/custom.js', 'resources/assets/js/libs/gmap.js', 'resources/assets/js/libs/ipad.js', 'resources/assets/js/libs/jquery.form.min.js', 'resources/assets/js/libs/jquery.min.js', 'resources/assets/js/libs/jquery.pjax.js', 'resources/assets/js/libs/jquery.slim.min.js', 'resources/assets/js/libs/myform.js', 'resources/assets/js/libs/sb-admin-2.js', 'resources/assets/js/libs/sb-admin-2.min.js', 'resources/assets/js/libs/sticky.js', 'resources/assets/js/libs/template.js' ], 'public/js/libs.js', './');
I think all paths should be relative to the root of the project (where webpack.mix.js is). Try
mix.styles([
'resources/assets/css/libs/animate.css',
//...
], 'public/css/libs.css')
mix.scripts([
'resources/assets/js/libs/app.js',
//...
], 'public/js/libs.js')
After much research I was able to use a laravel project to determine the reason for the empty files. The right syntax should have bee some like this:
mix.js('resources/assets/js/app.js', 'public/js/libs.js')
.sass('resources/assets/sass/app.scss', 'public/css/libs.css');
I should have specified destination file, so the right syntax would be some thing similar to:
```
const { mix } = require('laravel-mix');
mix
.js('resources/assets/js/app.js', 'public/js/app.js')
.js('resources/assets/js/bootstrap.js', 'public/js/app.js')
.js('resources/assets/js/plugins/jquery.appear.js', 'public/js/plugins/jquery.appear.js')
.js('resources/assets/js/plugins/jquery.backstretch.min.js', 'public/js/plugins/jquery.backstretch.min.js')
.js('resources/assets/js/plugins/modernizr.js', 'public/js/plugins/modernizr.js')
.combine([
'resources/assets/js/libs/app.js',
'resources/assets/js/libs/bootstrap.js',
'resources/assets/js/libs/custom.js',
'resources/assets/js/libs/gmap.js',
'resources/assets/js/libs/ipad.js',
'resources/assets/js/libs/jquery.form.min.js',
'resources/assets/js/libs/jquery.min.js',
'resources/assets/js/libs/jquery.pjax.js',
'resources/assets/js/libs/jquery.slim.min.js',
'resources/assets/js/libs/myform.js',
'resources/assets/js/libs/sb-admin-2.js',
'resources/assets/js/libs/sb-admin-2.min.js',
'resources/assets/js/libs/sticky.js',
'resources/assets/js/libs/template.js',], 'public/js/libs/libs.js')
.js('resources/assets/js/isotope/isotope.pkgd.min.js', 'public/js/plugins/isotope/isotope.pkgd.min.js')
.sass('resources/assets/sass/app.scss', 'public/css/lib.css')
.version();
```
The combine syntax should have been used to combine my javascript files.
Help source:
https://github.com/udoyen/blender

laravel route work wrong to direct to views

I am a new laraveler, now I work with a problem about laravel. I want the / direct to a anguler index.html. and others route to laravel controller. but when the \ direct well . the others routes work wrong to a views directory.
the \app\Http\route.php like follows :
Route::get('/',function(){
return File::get(public_path().('/views/index.html'));
});
Route::get('scan', "userController#Scan");
Route::get('check', "userController#Check");
Route::get('login', "userController#Login");
the directy is something like follows:
├── app
│ ├── Http
│ │ ├── route.php //route file
│ ├── Library
│ ├── Providers
│ ├── Services
│ ├── User.php
│ └── views
│ │ ├── Index.php // php index file , the entry for nginx server
│ └── ..........
├── bootstrap
│ ├── app.php
│ ├── autoload.php
│ └── cache
├── config
│ ├── app.php
│ └── view.php
│ └── ..........
├── public
│ ├── bower_components
│ ├── css
│ ├── data
│ ├── index.bak
│ ├── index.html //angular index file
│ └── scripts
│ └── ..........
now when I access to http://hostname/scan it comes 404 no found.
and the log like follows:
```
*2221 open() "/service/angular-laravel/app/views/scan" failed (2: No such file or directory), client: x.x.x.x, server: hostname, request: "GET /scan HTTP/1.1", host: "banliyun.com:8081"
```
as I was a little confuse with how the route work. can someone tell me why it will route to /views directory where place the laravel index page.
Save your index.html as index.blade.php in /resources/views/index.blade.php and you change your route to the following code:
Route::get('/', function(){
return view('index');
});
In AppServiceProvider class boot method add below line:
View::addLocation(public_path('views'));
Rename index.html file as index.blade.php and then follow below line in your route.php
Route::get('/', function(){
return view('index');
});

Symfony 2 FOSUserBundle: Override form without defining service

I' m trying to set up FOSUserBundle for my new application, so I want to override the default FOSUser form. As stated in the FOSUser documentation, I have to define my new form as a service before set up the app/config.yml appropriately. My question is why can't I just set up config.yml like this:
fos_user:
db_driver: orm
firewall_name: admin_area
user_class: abc\abcBundle\Entity\User
registration:
form:
type: abc\abcBundle\Form\Type\UserType
In my last application, I used FOSUserBundle along with PUGXMUltiUserBundle and then my (perfectly working) configuration for PUGXM was:
users:
agents:
entity:
class: abc\NikBundle\Entity\agents
registration:
form:
type: abc\NikBundle\Form\Type\UserType
name: agent_user_registration_form
template: abcNikBundle:ManageUsers:newUser.html.twig
so I supposed this can also be done with FOSUserBundle. Is it impossible and if yes why?
FOSUserBundle allows you to override it's controllers as described in the doc below
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_controllers.md
This doc actually shows you how to override registration controller and from there it's simply injecting your custom form for validation as in any normal controller.
You can also override the templates by finding the original FOSUserBundle templates under "{ROOT_DIR}/vendor/friendsofsymfony/user-bundle/Resources/views" and copying them into "{ROOT_DIR}/app/Resources/FOSUserBundle/views".
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md
It should look like this
Resources
└── FOSUserBundle
└── views
├── ChangePassword
│ ├── changePassword.html.twig
│ └── changePassword_content.html.twig
├── Registration
│ ├── confirmed.html.twig
│ ├── register.html.twig
│ └── register_fail.html.twig
├── Resetting
│ ├── checkEmail.html.twig
│ ├── email.txt.twig
│ ├── passwordAlreadyRequested.html.twig
│ ├── request.html.twig
│ ├── request_content.html.twig
│ ├── reset.html.twig
│ └── reset_content.html.twig
├── Security
│ └── login.html.twig
└── layout.html.twig

cakephp: running diffrent cakephp verison on same domain

I have already installed cakephp verion 1.3 on root of domain for Application1.
Now i want to develop another music application, that i want to store in a sub-directory. Now i want to use latest cakephp version for this application.
I am new to cakephp, and donot want to use same cakephp core for both application. First root application was not developed by me.
Directory structure is a s follow.
ROOT
├── .htaccess
├── cake
│ ├── config
│ ├── console
│ ├── libs
│ ├── tests
├── app
│ │ ├── .htaccess
│ │ ├── libs
│ │ ├── vendors
│ │ ├── config
│ │ ├── plugins
│ │ ├── views
│ │ ├── models
│ │ ├── controllers
│ │ ├── temp
│ │ ├── WEBROOT
│ │ │ ├── .htaccess
├──music (this one i want to use for latest version cakephp installation).
I installed cakephp 2.5.2 in music directory, but unable to access this by www.example.com/music/
It redirect to first root application i.e. example.com/member/index.
In
├── app
│ │ ├── config
│ │ ├ ├──routes.php
I have this:
Router::connect('/', array('controller' => 'members', 'action' => 'index'));
If unable to understand what i want:
My Question:
How can i run two different cakephp version, one on root of the domain
and second in subdirectory (music).
If not possible i will use same version, but one application will be in music sub directory.
Both the versions should work fine, just make sure you have not written a htaaccess rule to redirect all incoming request to the first cakephp folder.

Categories