aliasio / swiftlet Goto Github PK
View Code? Open in Web Editor NEWQuite possibly the smallest MVC framework you'll ever use.
Home Page: http://swiftlet.org
License: MIT License
Quite possibly the smallest MVC framework you'll ever use.
Home Page: http://swiftlet.org
License: MIT License
Hi,
Firstly thanks for creating this, look like it's exactly what I'm looking for!
Though I have an issue that I have fixed with a bit of a hack. But i'm not sure if I was just doing something wrong in the first place.
I have my file structure like this:
Controllers
--Index.php
--Admin
---- Login.php
---- Index.php
Now I thought I should have been able to just call /admin_login/ to call the login controller. if I went to admin_index it would work fine. But not admin_login.. I had named the login and index classes Admin_Login, Admin_Index... Not sure if i was supposed to do that but it make Admin_Index work.
The error thrown was a on the autoloader it couldn't find the file.. It's not caught as a 404 because at :
!is_file('Swiftlet/Controllers/' . $controllerName . '.php') << This point
$controllerName = 'Swiftlet\Controllers' . basename($controllerName); <<< This hasn't yet happened
at that point you lose the /admin/ from the file location..
$controllerName = 'Swiftlet\Controllers' . str_replace("/",'',$controllerName);
I changed it to the above as a bit of a hack... Then renamed the classes from Admin_Index, Admin_Login to just Login and Index.
I'm not sure if I'm just doing something wrong so any input would be appreciated
Dunno if known, latest RC gives 500 for not setting on mod_rewrite. (clean install)
MESSAGE:
Undefined index: children
FILE: C:\wamp\www\koten\swiftlet\admin\pages\index.php
LINE: 330
NO: 8
.htaccess is missing in download, this makes an error when using TRUE on URL rewrite in _config.php
As per the title.
Hi.
When I try to install a plugin I have this error :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '{versions} ( id
INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, plugin
VARCHAR(255' at line 1
CREATE TABLE {versions} ( id
INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, plugin
VARCHAR(255) NOT NULL, version
VARCHAR(10) NOT NULL, PRIMARY KEY (id
), UNIQUE plugin
(plugin
) ) ENGINE = INNODB;
Cheers.
Swiftlet_1.1.2.zip doesn't contain only 1 file called Swiftlet_1.1.2 its .zip / .rar file, but needs rename
maybe a bad rar program ?
I'm currently having some issues with the viewing model, when adding a simple in the template/view files, one could access all dataflow. Including admin password & mysql data.
I know nobody should access these files, but isn't that leaving a door open wide ?
I have a question on how to include or require a certain library. I don't have problems including a library directly into the index.php
file around where the App.php
is loaded but I don't want to always include all the libraries if they are not required. So I would like to include a library in the Controller
but all I get is a 500 error and no exception description. How can I fix this?
when creating a new user, from admin panel, swiftlet returns an error, saying the "edit-pasword" has not been filled, while the field is not given.
Big changes last days, have to get used to it :) Where should be the lib folder, probably in the root.
Anyways, I have one idea. At the moment you can get either from View or Application the name of
the view in string. This is useful if you want to know which View you are in for example. But there
is no function to get the name of a controller like getName()
in Controller or getController()
in
the Application. Would be great to also get the name of the Controller somehow in string.
In the App::run() function the $_rootPath doesn't get set if the FILE an $_SERVER['DOCUMENT_ROOT'] are not the same which can be a case of a virtual directory.
Good day!
Is it possible to use this framework with build-in PHP server or it's mandatory to use apache/nginx?
So I see there's some extra stuff in the code...
In \Swiftlet\App.php
every model is instantiated with 3 arguments.
public function getModel($modelName)
{
$modelName = 'Swiftlet\Models\\' . ucfirst($modelName);
// Instantiate the model
return new $modelName($this, $this->view, $this->controller);
}
But the \Swiftlet\Model.php
has only one argument in definition. Comment is written for three.
/**
* Constructor
* @param object $app
* @param object $view
* @param object $controller
*/
public function __construct(Interfaces\App $app)
{
$this->app = $app;
}
\Swiftlet\Interfaces\Model.php
has also just one argument defined.
I think at the moment it is impossible to get the Controller's title either from $this->app or directly from the Controller.
It is possible to add 2 permissions to 1 person. resulting in 'admin' having 2 roles.
In the Controller of Error 404 there is in the default action the following:
header("Status: 404 Not Found");
On php.net it's written that "For FastCGI you must use the code above for a 404 response".
However not every server runs FastCGI so I suggest adding both variations:
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
Otherwise the server doesn't respond with error header so that's not really good.
View Swiftlet\View->set(string $variable [, string $value ])
Would be great if you could by default also set objects or arrays.
I think using htmlEncode() by default is not really necessary and
could be like a parameter wish.
Just a notice that the app is case-sensitive for routing. Views /test and /Test are not the same. Controllers will be the same but not views so this should be discussed.
FAILED: Uploading a file in /admin/files/.
clean install, no folders changed. windows & wamp
I noticed that the 'plugin' field length is 256 as stated here, which raised an error on my local MySQL server (and maybe for others too??). I've fixed this by changing 'plugin' field length to 255.
Specified key was too long; max key length is 767 bytes
PS : I love Swiftlet's simplicity anyway :)
I think it would be great to have some kind of mechanism to also set variables for the Controller.
For example I have plugins or hooks made for session start and for authorization purposes and I would need to pass the authorization status to a Controller. I can pass now to View and read from it in a Controller but that's not so nice. Would be great to also have Controller->set()
and Controller->get()
.
If you pass an object from the controller to the view, the string properties of the object are html encoded over and over again each time you access the object in the view.
In controller:
$o->string1 = "&";
$this->view->o = $o;
In view:
echo $this->o->string1; // &
echo $this->o->string1; // &
echo $this->o->string1; // &amp;
....
In the App.php all the lines with:
throw new Exception
should be corrected to:
throw new \Exception
Maybe in some other files too, didn't check.
unit tests :
FAILED: Uploading a file in /admin/files/.
in index there is $new_plugins, this should be $newPlugins ;)
if ( count($newPlugins) )
{
$view->notices[] = $model->t(
'%1$s Plug-in(s) require installation (go to %2$s).',
array(
count($newPlugins),
'/installer/
'
)
);
}
Its small, but here is already a db connection check even before entering the plugin install, while at that point, you still don't know if i'm going to use that database. :)
After setting up a test for the framework I encountered an error with the title. I can scroll to the far right (didn't knew it could go this far) and saw the title of the website there.
A screenshot: http://www.betadevil.nl/error1.tiff
Hi, just stumbled upon your framework and am quite interested in using it for some smaller projects, the tiny footprint is very neat especially considering that it still manages to fulfil the basic needs of a framework.
One thing I don't like about it though is that you're not actually utilising namespaces, the only use you get out of them right now is that you will be able to easily embed your framework with other libraries or even other frameworks, but that's not a very feasible scenario to begin with.
You're still forcing users to use class names like "IndexController" whilst namespaces would allow you to just name it Index within the namespace Swiftlet\Controllers. Personally I would much favour this approach as I've never been a fan of mixing the namespace inside the class name, sure it works.. and it's easy with legacy IDE's.. but then what's the point of using namespaces to begin with.
Anyway, would love to hear what your thoughts are on this, looking forward to seeing where this framework might go.
Hi.
I just downloaded Swiftlet that I didn't know and when I tried to install I had this error :
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\wamp\www\swiftlet_controllers\Installer.php on line 179
A comma is missing at the end of the line 178 : ':version' => $this->outdatedPlugins[$plugin]->version
Cheers.
/*
i know the var is made +/- 10 lines above it but still true|false seems misplaced here.
As I'm using Swiftlet for some time now I would sure wish that the view files get splitted into actions. Having one view file for the whole controller can get quite messy if there are plenty of actions. Instead it would be maybe better if view files get splitted into {controller}_{action}.html.php
Hey,
First of all great tiny little useful framework. Am working on it at the moment.
But if I put a variable $_POST['bla'] in a controller and with no error reporting I get nothing.
But if I use error reporting then I get this error:
Warning: Invalid callback Swiftlet\App::error, cannot access private method Swiftlet\App::error() in controllers/IndexController.php on line 16
Apparently you can't reach error() function that is in App from a Controller.
It's a warning and it can be dismissed but I don't like just ignoring warnings.
FAILED: Uploading a file in /admin/files/.
on a windows system (no chmodd)
i have installed framework on my system but when i try to login in it username n password (sysPassword) it doesnt login in......plz help me..... im new to this framework want to learn more on this framework....
Warning: require(../../_model/init.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\swift\installer\index.php on line 13
Fatal error: require() [function.require]: Failed opening required '../../_model/init.php' (include_path='.;C:\php5\pear') in C:\wamp\www\swift\installer\index.php on line 13
changing (installer/index.php)
$contrSetup = array(
'rootPath' => '../../',
'pageTitle' => 'Plug-in installer'
);
to
$contrSetup = array(
'rootPath' => '../',
'pageTitle' => 'Plug-in installer'
);
fixes this issue
Don't really know if this issue is made by me or by swiftlet, but when i enter a link in page plugin, it returns in html as : localpath/url instead of url. In the database its normal url, ...
latest alfa version of swiflet
I would really like to start off by saying this is one of the best lightweight MVC frameworks out there. I am certainly using this on all my projects and this will give them the structure and standards they need right out of the box. I have looked at hundreds and none follow any good standard.
As you highlight in your Readme it does not include an ORM which is a shame as most if not all projects this will be used on will included some sort of database. Of course anyone can add one but I feel that it will always be more of a hack job and an after thought the part of the core.
There are many great ORM's out there and I have integrated PHP ActiveRecord. But I am not the most advanced php programmer so I know the way I have integrated it will probably break all the good standards in the framework.
The main issue I was having was with the namespaces. For example in my controller it would access the model and find records by User::find('all'). However I would get and error that class could not be found because the namespaces would get appended. So it would look for the module class Swiftlet\Controllers\User. Obviously getting the Swiftlet\Controller\ from the controller it is in.
I can work around it by using \User::find('all') instead but I feel that again breaks the standards and the spirit of the framework.
Thanks again.
After setting up a test for the framework I encountered an error with the title. I can scroll to the far right (didn't knew it could go this far) and saw the title of the website there.
A screenshot: http://www.betadevil.nl/error1.tiff
I used 1.2.0 Alpha 4
Thank you for this framework, I really like it, and fit my requirements for my new project
I have quick question, how to handle different route method such as get, post, etc in controller?
files get renamed from **.mp3 or **.txt to strings like "28b95f28ce2ee40ff93aa0dab7814d2b713592b7" and bcous of that, they don't link right :)
using the menu there is a default node/0 tho the script doesn't use it in the href so its impossible to use node/0
I'm working on a new project and I'm trying out Swiftlet - I like it very much so far. One problem I encountered, however, is the autoloader.
/Swiftlet/App.php
has an autoload
function which is registered using spl_autoload_register
. But it seems the autoload function makes no attempt to check if the file exists. So if I run some code using class_exists
, the autoload function will attempt to load the file, resulting in an error.
Another problem related to this is being able to register multiple autoloaders. In another issue - #40 - you suggest copying and modifying the autoload function from /Swiftlet/App.php
and updating the call to spl_autoload_register
to use the new function. But considering the documentation for spl_autoload_register
states:
If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined.
I think it might be better to allow users to register their own autoloaders to run in combination with Swiftlet's. And for that to work properly, it seems there needs to be a check for the existence of the file before require
ing it. I've done this myself by extending Swiftlet/App
and overriding the autoload function to add: if (file_exists($file)) require $file;
Oops! An error occured.
[ DEBUG MODE ]
MESSAGE:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"0", 25' at line 1
SELECT id
, username
FROM sw_users
ORDER BY username
LIMIT "0", 25;
FILE: /var/www/sw/_app/plugins/Db.php
LINE: 346
NO: 1064
CWD: /var/www/sw
[ BACKTRACE ]
Currently in 2018, this framework is still up or in stand by?
public function __construct(Swiftlet\Interfaces\App $app)
{
parent::__construct ($app);
}
Declaration of Swiftlet\Model\Article::__construct() must be compatible with Swiftlet\Interfaces\Model::__construct(Swiftlet\Interfaces\App $app) in /Applications/MAMP/htdocs/api2/Swiftlet/Models/Article.php on line 9
Hey,
me again. There could be a problem with the action name if the URL is like domain.com/flats/two-bedroom. Then the action would be 'two-bedroom' which is SEO friendly but there cannot be dashes in a Controller's method name. So there can't be two-bedroom() method. I would just suggest to correct App.php and use maybe: $this->action = str_replace('-', '_', $action);
I don't know if this is a real "issue" but I wondered why the field owner in user plugin, is actually a INT(1) while a tintyInt seems more then enough for the bool function it has. Now, I am a really noob at designing database so sorry if I mis a point here.
I think it would be also great to sort View file structure to Controller and View. At the moment you get from IndexController
and indexAction
just index.html.php
. It's a bit hard and too much work to separate each View by the action inside a file, would be just better to separate the view into index_action.html.php
or something since you can't call two actions at same time anyway.
For some reason google seems to get linked to these kind of links; for some reason... any idea
http://www.***.be/$1
http://www.***.be/page//aanmeld_hulp?permalink=aanmeld_hulp
Main index file is missing, no .htaccess file provided either.
After cloning to local server and running composer i can only access /public/ though the url.
The rewrites of url in App class are done server-side and due to no htaccess my server cannot recognize the path layout. Anything other than /public throws 404.
I can call function from controller by get: ?q=index/other. But still i can`t access any other controller than the one hardcoded as in public/index.php
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.